예제 #1
0
    public override void Init()
    {
#if USE_TIMMER_BEHAVIOUR
        if (!isAddToTimer)
        {
            startTimmer(2, UpdateBehaviourOnTimer.TIMER_THREAD_MID);
            isAddToTimer = true;
        }
#endif

        //animator = GetComponent<Animator>();
        creature        = GetComponent <Transform>();
        creaturePropety = GetComponent <CreatureProperty>();
        //castLayer = GetComponent<ScreenCastLayer>();

        if (null == m_stateHandlers)
        {
            m_stateHandlers = new ICreatureState[(int)EntityState.MaxCount];
        }
        m_stateHandlers[(int)EntityState.Standing] = new MonsterState_Standing(this);
        m_stateHandlers[(int)EntityState.Dead]     = new MonsterState_Dead(this);

        ChangeState((int)EntityState.Standing, IntPtr.Zero);

        //只和default做检测
        Y_AdjustLayerMask = 1 << LayerMask.NameToLayer(Config.LayerDefault) | 1 << LayerMask.NameToLayer(Config.LayerBuilding);
    }
예제 #2
0
 /// <summary>
 /// Constructor for creature sense
 /// </summary>
 /// <param name="settings">Ability settings</param>
 /// <param name="radius">Value of sight radius</param>
 /// <param name="state">Creature state</param>
 /// <param name="metabolism">Creature metabolism</param>
 /// <param name="transform">Creature transform</param>
 public CreatureSense(AbilitySettings settings, float radius, ICreatureState state, ICreatureMetabolism metabolism, Transform transform)
 {
     this.settings   = settings;
     Radius          = radius;
     this.state      = state;
     this.transform  = transform;
     this.metabolism = metabolism;
 }
    void Awake()
    {
        state      = new CreatureState();
        metabolism = new CreatureMetabolism(gameObject, settings.StartingEnergy);

        size            = new CreatureSize(sizeSettings, settings.Size, metabolism, transform);
        sense           = new CreatureSense(senseSettings, settings.SenseRadius, state, metabolism, transform);
        movement        = new CreatureMovement(velocitySettings, settings.Velocity, state, metabolism, sense, transform);
        creatureFactory = new CreatureFactory(gameObject, this, metabolism, transform, settings.Size);
    }
예제 #4
0
    /// <summary>
    /// Constructor for creature velocity
    /// </summary>
    /// <param name="settings">Ability settings</param>
    /// <param name="velocity">Velocity value</param>
    /// <param name="state">Creature state</param>
    /// <param name="metabolism">Creature metabolism</param>
    /// <param name="sense">Creature sense</param>
    /// <param name="transform">Creature transform</param>
    public CreatureMovement(AbilitySettings settings, float velocity, ICreatureState state, ICreatureMetabolism metabolism, ICreatureSense sense, Transform transform)
    {
        Velocity        = velocity;
        this.state      = state;
        this.transform  = transform;
        this.settings   = settings;
        this.metabolism = metabolism;
        this.sense      = sense;

        moveSpot = CreateMoveSpot();
    }
 public void SetState(ICreatureState state)
 {
     CurrentState = state;
 }
 public SpeakingCreatureWithState()
 {
     CurrentState = new FrogState(this as IStateContext);
 }