Exemple #1
0
    public MeleeAttackBehaviour(GameEntity entity, Transform transform) : base(entity, transform)
    {
        movement = entity.movement;
        combat   = entity.combat;
        sensing  = entity.sensing;
        unitAI   = entity.unitAI;

        nextUpdateDestinationTime = Random.Range(0, updateDestinationInterval);
    }
    public override void SetUpEntityComponent(GameEntity entity)
    {
        base.SetUpEntityComponent(entity);
        myTransform = entity.transform;
        sensing     = (entity as Fishie).sensing;
        actions     = (entity as Fishie).actions;
        ressources  = (entity as Fishie).ressources;

        currentWanderDestination = Vector2.zero;
    }
    protected override void Start()
    {
        sensing          = GetComponent <EC_Sensing>();
        movement         = GetComponent <EC_Movement>();
        playerController = GetComponent <EC_PlayerController>();
        fishieAI         = GetComponent <EC_FishieAI>();
        ressources       = GetComponent <EC_Ressources>();
        actions          = GetComponent <EC_Actions>();

        //setup all attached components
        if (playerController != null)
        {
            components = new GameEntityComponent[] { sensing, movement, actions, ressources, playerController }
        }
        ;
        else if (fishieAI != null)
        {
            components = new GameEntityComponent[] { sensing, movement, actions, ressources, fishieAI }
        }
        ;

        base.Start();
    }
}