zoukankan      html  css  js  c++  java
  • Chicken的代码解剖 :4 ChickenPawn_Chicken一小部分

      看看鸡是怎么被狐狸抓住的。在鸡的类中

    var Controller CarriedBy;

      这是狐狸的Controller,在上一节中我们学到,将鸡的Controller换为狐狸的就实现了他们两个之间的位置同步。然而还有一个插槽,让鸡飞到狐狸的嘴边,这样看起来像被叼着不是吗。

    function NotifyGrabbed(Controller Grabber)
    {
     super.NotifyGrabbed(Grabber);
    }

      原来我们在ChickenPawn类中漏掉了一个重要的函数,赶快把他拉过来看看。

    function NotifyGrabbed(controller Grabber)
    {
     ChickenAIController(controller).NotifyGrabbed(Grabber);
    }

      好吧,我们又被踢到类ChickenAIController中了,现在进入该类。

    function NotifyGrabbed(Controller Grabber)
    {
     GotoState('Grabber');
    }

      但愿你不会很烦,进入Grabber状态一探究竟。究竟是为什么要在Controller的状态中定义这么一套狐狸抓小鸡的动作呢?我们知道,狐狸和鸡都继承自这个Controller。

    State Grabber
    {
    //设置其物理为飞
       simulated event BeginState(name PreviousStateName)
       {
        Pawn.SetPhysics(PHYS_Flying);
        ClearTimer('CheckStuckTimer');
       }
    
    //在结束的时候将其速度设为0   
       simulated event EndState(name NextStateName)
       {
        StopLatentExecution();
        Pawn.velocity*=0;
       }
    
    //一会看看怎么定义外部Tick函数的   
       simulated event Tick(float DeltaTime)
       {
        super.Tick(DeltaTime);
       }
    
       
       function UpdateDragLocation(vector NewDragLocation)
       {
        Pawn.SetPhysics(PHYS_Flying);
      
      //只要被拖拽那就停止状态  
        if(VSize(currentDragPoint-NewDragLocation>100)
        StopLatentExecution();
      
      //目前的位置和被拖拽位置是一样的。  
        currentDragPoint=NewDragLocation;
       }   
    }

    然而ChickenController_Chicken中也存在State Grabbed。不过暂时没什么重要内容。重要的地方在于AIController_Fox中,进入其State DragPrey。Tick函数

    event Tick(float DeltaTime)
    {
     local vector newloc;
     local rotator newRot;
    
     //这里是最重要的,拖小鸡
     if(currentGrabbedPrey!=none)
     {
      GetCarryPosition(newLoc,newRot);
      Interface_DraggableItem(currentGrabbedPrey).UpdateDragLocation(newLoc,self,true,newRot);
     }
    
     super.Tick(DeltaTime);
    
    }
  • 相关阅读:
    Pandas Dict到DataFrame Series到DataFrame 转换
    MySQL锁和事务
    MySQl创建用户和授权,mysquldump
    MySQL索引
    pymysql模块
    Navicat下载安装
    MySQL多表查询
    学习目录
    MySQL单表查询
    MySQL逻辑查询语句的执行顺序
  • 原文地址:https://www.cnblogs.com/NEOCSL/p/2764222.html
Copyright © 2011-2022 走看看