Exemplo n.º 1
0
    // Use this for initialization
    protected void Start()
    {
        className  = this.GetType().ToString();
        rb         = GetComponent <Rigidbody2D> ();
        sr         = GetComponent <SpriteRenderer> ();
        colli      = GetComponent <Collider2D> ();
        halfWidth  = colli.bounds.extents.x;
        halfHeight = colli.bounds.extents.y;

        // build animations
        anim = GetComponent <Animator> ();
        AnimationClip[] clips = anim.runtimeAnimatorController.animationClips;
        foreach (AnimationClip clip in clips)
        {
            animationClipTable [clip.name] = clip;
        }

        // build actions
        //actionTable [Action.Type.Attack] = new AttackAction (this);
        actionTable [Action.Type.Attack] = new AttackShootAction(this);
        ((AttackShootAction)actionTable [Action.Type.Attack]).SetSprite("Graphic/arrow");
        //actionTable [Action.Type.JumpAttack] = new JumpAttackAction (this);
        actionTable [Action.Type.JumpAttack] = new JumpShootAttackAction(this);
        ((JumpShootAttackAction)actionTable [Action.Type.JumpAttack]).SetSprite("Graphic/arrow");
        //actionTable [Action.Type.Defend] = new RushAction (this);
        //actionTable [Action.Type.Defend].SetNextAction (Action.Type.Attack);
        actionTable [Action.Type.Damage] = new DamageAction(this);
        actionTable [Action.Type.Climb]  = new ClimbAction(this);
        actionTable [Action.Type.Dead]   = new DeadAction(this);
        //actionTable [Action.Type.Rush] = new RushAction (this);
        // wall jump
        // edge + jump -> climb up
        // combo
        // pick up

        //actionTable [Action.Type.Attack].SetPlaySpeedByDuration (1f);

        // default attack
        AttackArea aa = GetComponentInChildren <AttackArea> ();

        aa.SetAttacker(this);
        aa.SetAttack(new SimpleAttack(10));

        info       = GetComponent <CharacterInfo> ();
        info.owner = this;
        info.HPBar = transform.Find("HP/Cur HP").gameObject;


        SimpleAIController simpleAI = gameObject.AddComponent <SimpleAIController>();

        simpleAI.SetReceiver(this);
        simpleAI.transform.parent = transform;
        AI = simpleAI;
    }
Exemplo n.º 2
0
    protected void Start()
    {
        base.Start();
        actionTable [Action.Type.Attack]     = new AttackAction(this);
        actionTable [Action.Type.JumpAttack] = new JumpAttackAction(this);
        actionTable [Action.Type.Defend]     = new DefendAction(this);

        AttackArea aa = GetComponentInChildren <AttackArea> ();

        aa.SetAttacker(this);
        aa.SetAttack(new SimpleAttack(20));
    }