void returnToStartPos()
 {
     //GetComponent<Transform>().position = startPos;
     //StartCoroutine(returnFromAttack());
     attSeq       = AttackSequence.RETURN;
     sequenceTime = 0;
 }
Exemple #2
0
 public ElementalEarth(RoomScene room, byte subType, FVector pos, Dictionary <string, short> paramList) : base(room, subType, pos, paramList)
 {
     this.Meta     = Systems.mapper.ObjectMetaData[(byte)ObjectEnum.ElementalEarth].meta;
     this.attack   = new AttackSequence(paramList);
     this.attSpeed = (sbyte)Math.Round((paramList != null && paramList.ContainsKey("speed") ? paramList["speed"] : 100) * 0.01 * BaseAttackSpeed);
     this.AssignSubType(subType);
     this.AssignBoundsByAtlas(2, 4, -4, -12);
 }
Exemple #3
0
 public FlairElectric(RoomScene room, byte subType, FVector pos, Dictionary <string, short> paramList) : base(room, subType, pos, paramList)
 {
     this.Meta     = Systems.mapper.ObjectMetaData[(byte)ObjectEnum.FlairElectric].meta;
     this.attack   = new AttackSequence(paramList);
     this.attSpeed = (sbyte)Math.Round(paramList == null || !paramList.ContainsKey("speed") ? BaseAttackSpeed : paramList["speed"] * 0.01 * BaseAttackSpeed);
     this.gravity  = FInt.Create(paramList == null || !paramList.ContainsKey("grav") ? 0 : paramList["grav"] * 0.01f * 0.5f);
     this.AssignSubType(subType);
     this.AssignBoundsByAtlas(2, 4, -4, -10);
 }
    public IEnumerator Attack(AttackSequence sequence, int index = 0)
    {
        var speed = animator.speed;

        var time = 0f;

        if (index < sequence.sequence.Length && sequence.sequence.Length > 0)
        {
            currentAttackCount--;
            bool triggerAttack = false;
            animator.CrossFade(sequence.sequence[index].AnimationPlay, sequence.sequence[index].crossFade);
            while (time < sequence.sequence[index].timeToFinish)
            {
                time += Time.deltaTime;
                if (triggerAttack == false && time >= sequence.sequence[index].enableAttackTriggerTime && time < sequence.sequence[index].disableAttackTriggerTime)
                {
                    sequence.sequence[index].onEnableAttackTrigger.Invoke();
                    triggerAttack = true;
                }
                else if (triggerAttack && time >= sequence.sequence[index].disableAttackTriggerTime)
                {
                    sequence.sequence[index].onDisableAttackTrigger.Invoke();
                    triggerAttack = false;
                }
                animator.speed = sequence.sequence[index].animatorSpeed;

                yield return(null);
            }
            animator.speed = speed;
            if (currentAttackCount > 0)
            {
                if ((index + 1) < sequence.sequence.Length)
                {
                    StartCoroutine(Attack(sequence, index + 1));
                }
                else
                {
                    StartCoroutine(Attack(attackSequences[0]));
                }
            }
        }
    }
Exemple #5
0
        public HoveringEye(RoomScene room, byte subType, FVector pos, Dictionary <string, short> paramList) : base(room, subType, pos, paramList)
        {
            this.Meta = Systems.mapper.ObjectMetaData[(byte)ObjectEnum.HoveringEye].meta;

            // Physics, Collisions, etc.
            this.physics        = new Physics(this);
            this.shellCollision = true;
            this.SetCollide(CollideEnum.NoTileCollide);

            // Assign Flight Behavior
            this.behavior = FlightBehavior.AssignFlightMotion(this, paramList);

            // Attack Details
            this.attack    = new AttackSequence(paramList);
            this.attSpeed  = FInt.Create(paramList == null || !paramList.ContainsKey("speed") ? BaseAttackSpeed : paramList["speed"] * 0.01 * BaseAttackSpeed);
            this.attSpread = FInt.Create(paramList == null || !paramList.ContainsKey("spread") ? 0.3f : paramList["spread"] * 0.01f * 0.3f);
            this.attCount  = (byte)(paramList == null || !paramList.ContainsKey("count") ? 1 : paramList["count"]);

            this.AssignSubType(subType);
            this.AssignBoundsByAtlas(6, 6, -6, -6);
        }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("space"))
        {
            attSeq = AttackSequence.MOVE_TO_ATTACK;
            // get target position
            target = GameObject.FindGameObjectWithTag("Enemy");

            sequenceTime = 0;
            attacked     = false;

            //GetComponent<Animator>().SetTrigger("MarleShoot");
            //GetComponent<Transform>().position = new Vector2(2, 0);
            //GetComponent<Rigidbody>().velocity = new Vector2(12, 0);
            //Instantiate(fireball, new Vector2(2.5f, 0), fireball.rotation);
        }

        switch (attSeq)
        {
        case AttackSequence.MOVE_TO_ATTACK:
            // move to attack position
            sequenceTime += Time.deltaTime;
            //GetComponent<Transform>().position = Vector2.Lerp(startPos,
            //	target.transform.position + attackPosOffset, sequenceTime / moveTime);
            if (sequenceTime >= moveTime)
            {
                // when movement done, go to ATTACK sequence
                attSeq       = AttackSequence.ATTACK;
                sequenceTime = 0;
            }
            break;

        case AttackSequence.ATTACK:
            if (!attacked)
            {
                attacked = true;
                GetComponent <Animator>().SetTrigger("MarleShoot");
                Transform clone = Instantiate(fireballTrans,
                                              GetComponent <Transform>().position + new Vector3(.5f, 1),
                                              fireballTrans.rotation);
                clone.GetComponent <FireballController>().setTarget(target);
                //fireballTrans.gameObject.setTarget(target);
            }
            break;

        case AttackSequence.RETURN:
            sequenceTime += Time.deltaTime;
            //GetComponent<Transform>().position = Vector2.Lerp(
            //	target.transform.position + attackPosOffset, startPos, sequenceTime / moveTime);
            if (sequenceTime >= moveTime)
            {
                attSeq       = AttackSequence.WAIT;
                sequenceTime = 0;
            }
            break;

        case AttackSequence.WAIT:
        // do nothing
        default:
            break;
        }
    }
 public void PlayAttackSequence(GameObject playerChar, AttackSequence attackSequence)
 {
     ninjaAttackSequence_1 = attackSequence;
     ninjaAttackSequence_1.Initialize(playerChar); // getting the trigger component script attached to 'playerChar'
     ninjaAttackSequence_1.TriggerAbility();
 }