Esempio n. 1
0
    //Construct the Finite State Machine for the AI Car behavior
    private void ConstructFSM()
    {
        //Get the list of points
        pointList = GameObject.FindGameObjectsWithTag("WandarPoints");

        Transform[] waypoints = new Transform[pointList.Length];
        int i = 0;
        foreach (GameObject obj in pointList)
        {
            waypoints[i] = obj.transform;
            i++;
        }

        PatrolState patrol = new PatrolState(waypoints);
        patrol.AddTransition(Transition.SawPlayer, FSMStateID.Chasing);
        patrol.AddTransition(Transition.NoHealth, FSMStateID.Dead);

        ChaseState chase = new ChaseState(waypoints);
        chase.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling);
        chase.AddTransition(Transition.ReachPlayer, FSMStateID.Attacking);
        chase.AddTransition(Transition.NoHealth, FSMStateID.Dead);

        AttackState attack = new AttackState(waypoints);
        attack.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling);
        attack.AddTransition(Transition.SawPlayer, FSMStateID.Chasing);
        attack.AddTransition(Transition.NoHealth, FSMStateID.Dead);

        DeadState dead = new DeadState();
        dead.AddTransition(Transition.NoHealth, FSMStateID.Dead);

        AddFSMState(patrol);
        AddFSMState(chase);
        AddFSMState(attack);
        AddFSMState(dead);
    }
        void FixedUpdate()
        {
            switch (attackState)
            {
                case AttackState.Attacking:
                    {
                        if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Attacking"))
                        {
                            attackState = AttackState.Neutral;
                        }

                        break;
                    }
                case AttackState.Neutral:
                    {
                        break;
                    }
                default:
                    {
                        print("Switch state not defined");
                        break;
                    }
            }
            
        }
Esempio n. 3
0
    void Awake()
    {
        Hp = InitialLifes = ConfigReader.GetConfig().GetField("hero").GetField("InitialLifes").n;
        AttackDistance = ConfigReader.GetConfig().GetField("hero").GetField("AttackDistance").n;
        AttackReloadPeriod = ConfigReader.GetConfig().GetField("hero").GetField("AttackReloadPeriod").n;
        Velocity = ConfigReader.GetConfig().GetField("hero").GetField("Velocity").n;
        AttackReactionPeriod = ConfigReader.GetConfig().GetField("hero").GetField("AttackReactionPeriod").n;
        AttackReloadPeriod = ConfigReader.GetConfig().GetField("hero").GetField("AttackReloadPeriod").n;
        MovingToDragTargetVelocity = ConfigReader.GetConfig().GetField("hero").GetField("MovingToDragTargetVelocity").n;
        HpPercent = 100;

        IdleState idleState = new IdleState(this);
        ConductorMoveState moveState = new ConductorMoveState(this);
        ConductorDragState dragState = new ConductorDragState(this);
        AttackState attackState = new AttackState(this);
        AttackedState attackedState = new AttackedState(this);
        FrozenState frozenState = new FrozenState(this);
        Dictionary<int, State> stateMap = new Dictionary<int, State>
        {
            {(int) MovableCharacterStates.Idle, idleState},
            {(int) MovableCharacterStates.Move, moveState},
            {(int) MovableCharacterStates.Drag, dragState},
            {(int) MovableCharacterStates.Attack, attackState},
            {(int) MovableCharacterStates.Attacked, attackedState},
            {(int) MovableCharacterStates.Frozen, frozenState}
        };
        InitWithStates(stateMap, (int)MovableCharacterStates.Idle);
    }
Esempio n. 4
0
	void Awake() {
		attackState = new AttackState(this);
		chaseState = new ChaseState(this);
		idleState = new IdleState(this);
		patrolState = new PatrolState(this);
		playerBuddy = GameObject.FindGameObjectWithTag("Player").transform;
		buddyScript = playerBuddy.GetComponent<Movement>();
	}
    /// <summary>
    /// Disenganges the unit from combat and starts them moving towrads their original destination.
    /// The unit will begin searching for new targets and will switch to their longest ranged weapon.
    /// </summary>
    public void Disengage()
    {
        mAttackState = AttackState.kIdle;
        mMovementState = MovementState.kMoving;

        SwitchToWeapon(mWeapons.Count - 1); // longest range weapon
        this.collider2D.enabled = true;
    }
Esempio n. 6
0
	void Awake () {
		wanderState = new WanderState (wanderTimeMin, wanderTimeMax, wanderSpeed, wanderRadius);
		idleState = new IdleState (idleTime);
		chaseState = new ChaseState (chaseTime, chaseSpeed);
		attackState = new AttackState ();
		deadState = new DeadState ();
		leaveAltarState = new LeaveAltarState ();
	}
    void Start()
    {
        Health = BOSS_MAX_HEALTH;
        m_HealthAmount.text = Health.ToString() + " / " + BOSS_MAX_HEALTH.ToString();

        m_RetreatPos = this.transform.position;
        m_State = AttackState.Idle;
        this.gameObject.SetActive(false);
    }
Esempio n. 8
0
    protected override void StartVirtual()
    {
        base.StartVirtual ();

        m_Agent = GetComponent<NavMeshAgent>();
        m_Agent.Stop ();

        m_Attack = GetComponent<AttackState>();
    }
    void Awake()
    {
        chaseState = new ChaseState(this);
        alertState = new AlertState(this);
        patrolState = new PatrolState(this);
        attackState = new AttackState(this);

        navMeshAgent = GetComponent<NavMeshAgent>();
    }
        public void Attack()
        {
            if (attackState == AttackState.Neutral)
            {
                attackState = AttackState.Attacking;
                startPos = transform.position;

                animator.SetTrigger("Attacking");
            }
        }
Esempio n. 11
0
    protected override void StartVirtual()
    {
        base.StartVirtual ();

        m_Agent = GetComponent<NavMeshAgent>();

        m_Attack = GetComponent<AttackState>();

        m_OrbitDirection = (Random.value <= 0.5f) ? -1.0f : 1.0f;

        m_Destination = transform.position;
    }
Esempio n. 12
0
 void Attack()
 {
     //		Debug.Log ( (!isAttacking) + " " + (attackState == AttackState.Idle));
     if (attackState == AttackState.Idle)
     {
         hasReleased = false;
         isAttacking = true;
         attackStartingTime = Time.time;
         attackState = AttackState.Lift;
         sword.Play ("Lift");
         sword.animationCompleteDelegate = LiftCompleteDelegate;
     }
 }
Esempio n. 13
0
    void AttackNotChargeCompleteDelegate(tk2dAnimatedSprite sprite, int clipId)
    {
        isAttacking = false;
        hasReleased = false;
        attackState = AttackState.Idle;
        chargeStage = ChargeStage.NotCharge;
        weaponDegree = weaponStartingDegree;

        if (Input.GetKey ("/"))
        {
            Attack ();
        }
        //		if (Input.touches.Length == 1)
        //			Attack ();
    }
Esempio n. 14
0
        public SwallowActor(Actor self, Target target, WeaponInfo weapon)
        {
            this.target = target;
            this.weapon = weapon;
            sandworm = self.Trait<Sandworm>();
            positionable = self.Trait<Mobile>();
            swallow = self.Trait<AttackSwallow>();
            renderUnit = self.Trait<RenderUnit>();
            radarPings = self.World.WorldActor.TraitOrDefault<RadarPings>();
            countdown = swallow.Info.AttackTime;

            renderUnit.DefaultAnimation.ReplaceAnim("burrowed");
            stance = AttackState.Burrowed;
            location = target.Actor.Location;
        }
Esempio n. 15
0
		public SwallowActor(Actor self, Target target, WeaponInfo weapon)
		{
			this.target = target;
			this.weapon = weapon;
			sandworm = self.Trait<Sandworm>();
			positionable = self.Trait<Mobile>();
			swallow = self.Trait<AttackSwallow>();
			withSpriteBody = self.Trait<WithSpriteBody>();
			radarPings = self.World.WorldActor.TraitOrDefault<RadarPings>();
			countdown = swallow.Info.AttackTime;

			withSpriteBody.DefaultAnimation.ReplaceAnim(sandworm.Info.BurrowedSequence);
			stance = AttackState.Burrowed;
			location = target.Actor.Location;
		}
Esempio n. 16
0
		bool WormAttack(Actor worm)
		{
			var targetLocation = target.Actor.Location;

			// The target has moved too far away
			if ((location - targetLocation).Length > NearEnough)
				return false;

			var lunch = worm.World.ActorMap.GetActorsAt(targetLocation)
				.Where(t => !t.Equals(worm) && weapon.IsValidAgainst(t, worm));

			if (!lunch.Any())
				return false;

			stance = AttackState.EmergingAboveGround;
			sandworm.IsAttacking = true;

			foreach (var actor in lunch)
			{
				var actor1 = actor;	// loop variable in closure hazard

				actor.World.AddFrameEndTask(_ =>
					{
						actor1.Dispose();

						// Harvester insurance
						if (!actor1.Info.HasTraitInfo<HarvesterInfo>())
							return;

						var insurance = actor1.Owner.PlayerActor.TraitOrDefault<HarvesterInsurance>();

						if (insurance != null)
							actor1.World.AddFrameEndTask(__ => insurance.TryActivate());
					});
			}

			positionable.SetPosition(worm, targetLocation);

			var attackPosition = worm.CenterPosition;
			var affectedPlayers = lunch.Select(x => x.Owner).Distinct().ToList();

			PlayAttack(worm, attackPosition, affectedPlayers);
			foreach (var notify in worm.TraitsImplementing<INotifyAttack>())
				notify.Attacking(worm, target, null, null);

			return true;
		}
Esempio n. 17
0
 private void Update()
 {
     //角色没死
     if (Input.GetMouseButton(0) && attackState != PlayerAttackState.Deadth && !EventSystem.current.IsPointerOverGameObject())
     {
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         bool       isClick = Physics.Raycast(ray, out hit);
         //如果检测到点击目标为怪物
         if (isClick && hit.collider.tag == Tags.enemy)
         {
             //转向目标
             transform.LookAt(hit.collider.transform.position);
             normal_target = hit.collider.transform;
             attackState   = PlayerAttackState.NormalAttack;
         }
         else
         {
             attackState   = PlayerAttackState.ControlWalk;
             normal_target = null;
         }
     }
     if (attackState == PlayerAttackState.NormalAttack)
     {
         if (normal_target == null)
         {
             attackState = PlayerAttackState.ControlWalk;
             return;
         }
         float distance = Vector3.Distance(transform.position, normal_target.position);
         if (distance <= min_attackDistance)
         {
             attack = AttackState.Attack;
             transform.LookAt(normal_target.position);
             timer += Time.deltaTime;
             anima.Play(current_anima);
             if (timer >= time_normalAttack)
             {
                 current_anima = anima_idle;
                 //当前攻击目标收到伤害
             }
             if (timer >= (1 / normalAttackSpeed))
             {
                 current_anima = anima_normalAttack;
                 normal_target.GetComponent <SmallEnemy>().TakeDamage(playerInfo.attack);
                 //怪物死亡目标消失
                 if (normal_target.GetComponent <SmallEnemy>().hp <= 0)
                 {
                     normal_target = null;
                 }
                 timer = 0;
             }
             //Debug.Log ("Damage="+GetNormalAttackDamage());
         }
         //
         else
         {
             //向目标移动
             attack = AttackState.Moving;
             playerMove.SimpleMove(normal_target.position);
         }
     }
     else if (attackState == PlayerAttackState.Deadth)
     {
         //anima.CrossFade(anima_Death);
         anima.Play(current_anima);
     }
 }
Esempio n. 18
0
    /// <summary>
    /// 奏でる
    /// </summary>
    public override bool Melody(ManageDungeon dun, PlayerCharacter player)
    {
        BaseCharacter[] targets;

        player.AttackInfo.Initialize();

        //音を鳴らす
        player.AttackInfo.AddVoice(VoiceInformation.VoiceType.Sing);

        switch (MType)
        {
        //放電
        case MelodyType.Electric:

            //サウンドを鳴らす
            player.AttackInfo.AddSound(SoundInformation.SoundType.ElectricMelody);

            const int ElectricDamage = 20;
            int       damage         = ElectricDamage + Mathf.FloorToInt(player.BaseAttack);

            //エフェクト
            player.AttackInfo.AddEffect(EffectSpark.CreateObject(player));

            //メッセージ
            player.AttackInfo.AddMessage(
                string.Format(CommonConst.Message.MelodySing, DisplayNameInMessage));

            //部屋の中のキャラクターを取得
            targets = dun.GetRoomCharacters(player);

            //全員にダメージ
            foreach (BaseCharacter c in targets)
            {
                AttackState atState = c.AddDamage(damage);

                //ダメージエフェクト
                EffectDamage d = EffectDamage.CreateObject(c);
                d.SetText(damage.ToString(), AttackState.Hit);
                player.AttackInfo.AddEffect(d);

                //ヒットメッセージ
                player.AttackInfo.AddMessage(
                    c.GetMessageAttackHit(damage));

                //対象が死亡したら
                if (atState == AttackState.Death)
                {
                    player.AttackInfo.AddKillList(c);

                    player.AttackInfo.AddMessage(
                        c.GetMessageDeath(c.HaveExperience));

                    player.Death(c, player.AttackInfo);
                }
            }


            break;

        //狂乱
        case MelodyType.Confusion:

            //サウンドを鳴らす
            player.AttackInfo.AddSound(SoundInformation.SoundType.Smoke);

            //メッセージ
            player.AttackInfo.AddMessage(
                string.Format(CommonConst.Message.MelodySing, DisplayNameInMessage));

            //部屋の中のキャラクターを取得
            targets = dun.GetRoomCharacters(player);

            //全員を混乱
            foreach (BaseCharacter c in targets)
            {
                //対象に混乱を付与
                int result = c.AddStateAbnormal((int)StateAbnormal.Confusion);
                //対象が混乱になったらメッセージを表示
                if (result != 0)
                {
                    player.AttackInfo.AddEffect(EffectSmoke.CreateObject(c));

                    player.AttackInfo.AddMessage(
                        CommonFunction.GetAbnormalMessage(StateAbnormal.Confusion, c));
                }
            }
            break;

        //まどろみ
        case MelodyType.Sleep:

            //サウンドを鳴らす
            player.AttackInfo.AddSound(SoundInformation.SoundType.Smoke);

            //メッセージ
            player.AttackInfo.AddMessage(
                string.Format(CommonConst.Message.MelodySing, DisplayNameInMessage));

            //部屋の中のキャラクターを取得
            targets = dun.GetRoomCharacters(player);

            //全員を睡眠
            foreach (BaseCharacter c in targets)
            {
                //対象に睡眠を付与
                int result = c.AddStateAbnormal((int)StateAbnormal.Sleep);
                //対象が睡眠になったらメッセージを表示
                if (result != 0)
                {
                    player.AttackInfo.AddEffect(EffectSmoke.CreateObject(c));

                    player.AttackInfo.AddMessage(
                        CommonFunction.GetAbnormalMessage(StateAbnormal.Sleep, c));
                }
            }
            break;

        //無秩序
        case MelodyType.Anarchy:

            //サウンドを鳴らす
            player.AttackInfo.AddSound(SoundInformation.SoundType.Smoke);

            //メッセージ
            player.AttackInfo.AddMessage(string.Format(CommonConst.Message.MelodySing, DisplayNameInMessage));

            //部屋の中のキャラクターを取得
            targets = dun.GetRoomCharacters(player);

            //全員をデコイ
            foreach (BaseCharacter c in targets)
            {
                //対象にデコイを付与
                int result = c.AddStateAbnormal((int)StateAbnormal.Decoy);
                //対象がデコイになったらメッセージを表示
                if (result != 0)
                {
                    player.AttackInfo.AddEffect(EffectSmoke.CreateObject(c));

                    player.AttackInfo.AddMessage(
                        CommonFunction.GetAbnormalMessage(StateAbnormal.Decoy, c));
                }
            }
            break;

        //薄ら日
        case MelodyType.Light:

            //エフェクト
            player.AttackInfo.AddEffect(EffectFlash.CreateObject());

            //サウンドを鳴らす
            player.AttackInfo.AddSound(SoundInformation.SoundType.Smoke);

            //メッセージ
            player.AttackInfo.AddMessage(string.Format(CommonConst.Message.MelodySing, DisplayNameInMessage));

            dun.IsVisible      = true;
            dun.IsEnemyVisible = true;
            dun.IsItemVisible  = true;
            dun.IsTrapVisible  = true;
            break;

        //角笛
        case MelodyType.Horn:

            //サウンドを鳴らす
            player.AttackInfo.AddSound(SoundInformation.SoundType.Summon);

            //エフェクトの発動
            player.AttackInfo.AddEffect(EffectSummon.CreateObject(player));

            int cnt = CommonFunction.ConvergenceRandom(3, 0.9f, 1.2f, 10);

            for (int i = 0; i < cnt; i++)
            {
                dun.SetUpCharacterMap();
                //敵の出現地点を取得
                MapPoint mp = dun.GetCharacterEmptyTarget(player.CurrentPoint);
                if (CommonFunction.IsNull(mp) == true)
                {
                    break;
                }

                int  enemytype           = TableEnemyMap.GetValue(dun.DungeonObjNo, DisplayInformation.Info.Floor);
                uint rand                = CommonFunction.GetRandomUInt32();
                BaseEnemyCharacter enemy = TableEnemyIncidence.GetEnemy(enemytype, rand, DisplayInformation.Info.Floor);

                enemy.SetCharacterDisplayObject(mp.X, mp.Y);
                dun.AddNewCharacter(enemy);
            }
            DisplayInformation.Info.AddMessage(
                CommonConst.Message.TrapSummon);

            break;

        // 忘却
        case MelodyType.Forget:

            //メッセージ
            player.AttackInfo.AddMessage(
                string.Format(CommonConst.Message.MelodySing, DisplayNameInMessage));

            //効果音
            player.AttackInfo.AddSound(SoundInformation.SoundType.Summon);

            if (dun.IsVisible == false)
            {
                for (int j = 1; j < dun.X - 1; j++)
                {
                    for (int i = 1; i < dun.Y - 1; i++)
                    {
                        dun.Dungeon.DungeonMap.Get(i, j).IsClear = false;
                    }
                }

                player.AttackInfo.AddMessage(CommonConst.Message.ForgetMap);

                player.AttackInfo.AddEffect(EffectSmoke.CreateObject(player));
            }

            break;

        //捨て置き
        case MelodyType.ThrowAway:

            //メッセージ
            player.AttackInfo.AddMessage(
                string.Format(CommonConst.Message.MelodySing, DisplayNameInMessage));

            player.AttackInfo.AddMessage(
                string.Format(CommonConst.Message.ThrowAway, player.DisplayNameInMessage));

            GameStateInformation.Info.IsThrowAway = true;

            break;
        }
        return(true);
    }
Esempio n. 19
0
 void Awake()
 {
     currState         = AttackState.Stop;
     currShootingState = ShootingState.StopShooting;
 }
Esempio n. 20
0
 public abstract bool IsTrue(AttackState state);
Esempio n. 21
0
    void Attack(bool attack)
    {
        offset = transform.position;
        switch (attackState)
        {
        case AttackState.Ready:
            if (attack)
            {
                switch (projectileDirection)
                {
                case Directions.Right:
                    offset.x  += 0.7f;
                    projectile = Instantiate(projectilePrefab, offset, Quaternion.Euler(0, 180, 0));
                    projectile.GetComponent <IProjectile>().SetDirection(Directions.Right);
                    if (knockback)
                    {
                        rigidbody2D.AddForce(Vector2.left * knockbackForce, ForceMode2D.Impulse);
                    }
                    break;

                case Directions.Left:
                    offset.x  -= 0.7f;
                    projectile = Instantiate(projectilePrefab, offset, Quaternion.Euler(0, 180, 0));
                    projectile.GetComponent <IProjectile>().SetDirection(Directions.Left);
                    if (knockback)
                    {
                        rigidbody2D.AddForce(Vector2.right * knockbackForce, ForceMode2D.Impulse);
                    }
                    break;

                case Directions.Up:
                    offset.y  += 0.7f;
                    projectile = Instantiate(projectilePrefab, offset, Quaternion.Euler(0, 180, 0));
                    projectile.GetComponent <IProjectile>().SetDirection(Directions.Up);
                    if (knockback)
                    {
                        rigidbody2D.AddForce(Vector2.down * knockbackForce, ForceMode2D.Impulse);
                    }
                    break;

                case Directions.Down:
                    offset.y  -= 0.7f;
                    projectile = Instantiate(projectilePrefab, offset, Quaternion.Euler(0, 180, 0));
                    projectile.GetComponent <IProjectile>().SetDirection(Directions.Down);
                    if (knockback)
                    {
                        rigidbody2D.AddForce(Vector2.up * knockbackForce, ForceMode2D.Impulse);
                    }
                    break;
                }
                attackState = AttackState.Attacking;
            }
            break;

        case AttackState.Attacking:
            attackTimer += Time.deltaTime * 3;
            if (attackTimer >= attackCooldown)
            {
                attackTimer = attackCooldown;
                attackState = AttackState.Cooldown;
            }
            break;

        case AttackState.Cooldown:
            attackTimer -= Time.deltaTime;
            if (attackTimer <= 0)
            {
                attackTimer = 0;
                attackState = AttackState.Ready;
            }
            break;
        }
    }
Esempio n. 22
0
 private AttackState NextInProgression()
 {
     m_progress = (m_progress == AttackState.INACTIVE) ? AttackState.STARTUP : m_progress + 1;
     return(m_progress);
 }
Esempio n. 23
0
 public void PoundAttack()
 {
     time  = 0;
     state = AttackState.POUND;
 }
Esempio n. 24
0
		public override Activity Tick(Actor self)
		{
			if (countdown > 0)
			{
				countdown--;
				return this;
			}

			// Wait for the worm to get back underground
			if (stance == AttackState.ReturningUnderground)
			{
				sandworm.IsAttacking = false;

				// There is a chance that the worm would just go away after attacking
				if (self.World.SharedRandom.Next() % 100 <= sandworm.Info.ChanceToDisappear)
				{
					self.CancelActivity();
					self.World.AddFrameEndTask(w => self.Kill(self));
				}
				else
					withSpriteBody.DefaultAnimation.ReplaceAnim(sandworm.Info.IdleSequence);

				return NextActivity;
			}

			// Wait for the worm to get in position
			if (stance == AttackState.Burrowed)
			{
				// This is so that the worm cancels an attack against a target that has reached solid rock
				if (!positionable.CanEnterCell(target.Actor.Location, null, false))
					return NextActivity;

				if (!WormAttack(self))
				{
					withSpriteBody.DefaultAnimation.ReplaceAnim(sandworm.Info.IdleSequence);
					return NextActivity;
				}

				countdown = swallow.Info.ReturnTime;
				stance = AttackState.ReturningUnderground;
			}

			return this;
		}
Esempio n. 25
0
 void UpdateIdle()
 {
     currMinionState = MinionState.Idle;
     currAttackState = AttackState.None;
 }
Esempio n. 26
0
    //Start overrides the virtual Start function of the base class.
    void Start()
    {
        //Register this enemy with our instance of GameManager by adding it to a list of Enemy objects.
        //This allows the GameManager to issue movement commands.
        GameManager.instance.AddEnemyToList(this);

        if (currentHealth == 0)
        {
            currentHealth = startingHealth;
        }

        nextRangeTime = rangedAttackCD;
        nextMeleeTime = meleeAttackCD;

        if (!canMove)
        {
            AttackRange = 3f;
        }

        baseSpeed = speed;
        if (isBoss)
        {
            if (chaseSpeed == 0)
            {
                chaseSpeed = speed + 2f;
            }
        }
        else
        {
            if (chaseSpeed == 0)
            {
                chaseSpeed = speed + 1f;
            }
        }

        if (cannotChase)
        {
            speed      = Random.Range(2, 7);
            chaseSpeed = speed;
            baseSpeed  = speed;
        }

        patrolState       = new PatrolState();
        attackState       = new AttackState();
        chaseState        = new ChaseState();
        rangedAttackState = new RangedAttackState();
        animator          = GetComponent <Animator>();
        if (canMove)
        {
            changeState(patrolState);
        }
        else
        {
            changeState(chaseState);
        }

        if (animator.GetBool("Moving"))
        {
            animator.SetBool("Moving", true);
        }
        healthbar = transform.FindChild("EnemyCanvas").FindChild("Healthbar").FindChild("Health").GetComponent <Image>();

        //if (isGhost)
        startingLoc = transform.position;

        roomId        = RoomManager.Instance.findRoomId(transform.position.x, transform.position.y);
        currentRoomId = roomId;
    }
Esempio n. 27
0
    //--------------------------Attack---------------------------------
    #region Attack
    private void Attack()
    {
        if (playerAnimatorState == PlayerAnimatorState.Movement || playerAnimatorState == PlayerAnimatorState.Attack || playerAnimatorState == PlayerAnimatorState.Avoid && IsGround)
        {
            if (Input.GetKeyDown(KeyCode.Q) && attackState == AttackState.Default /* && UI_HP.Ui_HP.MP >= 30*/)
            {
                if (CanAttack)
                {
                    // UI_HP.Ui_HP.MP -= 30;
                    attackState    = AttackState.BigSkill;
                    AttackTrigger += 1;
                    CanAttack      = false;
                }
            }
            else if (Input.GetMouseButtonDown(0)) //按下滑鼠左鍵
            {
                switch (attackState)              //用現現階段的狀態來判斷下一擊要觸發哪一個攻擊
                {
                case AttackState.Default:         //假如現階段為Default

                    if (CanAttack)                //判斷可以觸發下一階段的時機
                    {
                        if (IsFastRun)
                        {
                            switch (moveState)
                            {
                            case MoveState.FastRunForward:
                                DashAttack_Euler = Quaternion.Euler(0, RotationX, 0);
                                DashAttack_Pos   = DashAttack_Euler * new Vector3(0, 0, DashAttack_MaxDis) + transform.position;
                                break;

                            case MoveState.FastRunLeft:
                                DashAttack_Euler = Quaternion.Euler(0, RotationX - 45, 0);
                                DashAttack_Pos   = DashAttack_Euler * new Vector3(0, 0, DashAttack_MaxDis) + transform.position;
                                break;

                            case MoveState.FastRunRight:
                                DashAttack_Euler = Quaternion.Euler(0, RotationX + 45, 0);
                                DashAttack_Pos   = DashAttack_Euler * new Vector3(0, 0, DashAttack_MaxDis) + transform.position;
                                break;
                            }

                            DashAttack_StartTime = Time.time;
                            attackState          = AttackState.DashAttack;
                            AttackTrigger       += 1;
                            CanAttack            = false;
                        }
                        else
                        {
                            attackState    = AttackState.Attack_1; //則觸發後的下一階段為Attack_1,
                            AttackTrigger += 1;                    //用來限定Aniamtor.trigger只能觸發一次
                            CanAttack      = false;                //用來限定當攻擊的動畫還沒播完則不能觸發下一階段攻擊,需搭配Animation Event
                        }
                    }
                    break;

                case AttackState.Attack_1:
                    if (CanAttack)
                    {
                        attackState    = AttackState.Attack_2;
                        AttackTrigger += 1;
                        CanAttack      = false;
                    }
                    break;

                case AttackState.Attack_2:
                    if (CanAttack)
                    {
                        attackState    = AttackState.Attack_3;
                        AttackTrigger += 1;
                        CanAttack      = false;
                    }
                    /*  Debug.Log(AttackTrigger);*/
                    break;
                }
            }
            else if (Input.GetMouseButtonDown(1))
            {
                if (CanAttack && attackState != AttackState.BigSkill /*&& UI_HP.Ui_HP.MP >= 5*/ && attackState != AttackState.LongAttack)  //--
                {
                    attackState    = AttackState.LongAttack;
                    AttackTrigger += 1;
                    CanAttack      = false;
                }
            }
        }
        AttackAnimation();
    }
Esempio n. 28
0
    IEnumerator CancelAttack(float WaitTime)
    {
        yield return(new WaitForSeconds(WaitTime));//當過了WaitTime秒後則重置現階段狀態

        attackState = AttackState.Default;
    }
 public override bool IsTrue(AttackState state)
 {
     return(Value);
 }
 public void Completed()
 {
     this.AttackStatus = AttackState.Completed;
 }
Esempio n. 31
0
 public override void End()
 {
     world.RemoveBody(attackBody);
     state = AttackState.Ready;
 }
Esempio n. 32
0
 public CombatUnit()
 {
     skillList   = new List <Skill>();
     attackState = AttackState.none;
     AllUnits.Add(this);
 }
Esempio n. 33
0
        public override Activity Tick(Actor self)
        {
            switch (stance)
            {
            case AttackState.Uninitialized:
                GrantUpgrades(self);
                stance         = AttackState.Burrowed;
                countdown      = swallow.Info.AttackDelay;
                burrowLocation = self.Location;
                break;

            case AttackState.Burrowed:
                if (--countdown > 0)
                {
                    return(this);
                }

                var targetLocation = target.Actor.Location;

                // The target has moved too far away
                if ((burrowLocation - targetLocation).Length > NearEnough)
                {
                    RevokeUpgrades(self);
                    return(NextActivity);
                }

                // The target reached solid ground
                if (!positionable.CanEnterCell(targetLocation, null, false))
                {
                    RevokeUpgrades(self);
                    return(NextActivity);
                }

                var targets = self.World.ActorMap.GetActorsAt(targetLocation)
                              .Where(t => !t.Equals(self) && weapon.IsValidAgainst(t, self));

                if (!targets.Any())
                {
                    RevokeUpgrades(self);
                    return(NextActivity);
                }

                stance               = AttackState.Attacking;
                countdown            = swallow.Info.ReturnDelay;
                sandworm.IsAttacking = true;
                AttackTargets(self, targets);

                break;

            case AttackState.Attacking:
                if (--countdown > 0)
                {
                    return(this);
                }

                sandworm.IsAttacking = false;

                // There is a chance that the worm would just go away after attacking
                if (self.World.SharedRandom.Next(100) <= sandworm.Info.ChanceToDisappear)
                {
                    self.CancelActivity();
                    self.World.AddFrameEndTask(w => self.Dispose());
                }

                RevokeUpgrades(self);
                return(NextActivity);
            }

            return(this);
        }
Esempio n. 34
0
 private void SetAttackState(AttackState state)
 {
     Console.WriteLine(this.ToString() + " AttackState[" + attackState.ToString() + "->" + state.ToString() + "]");
     attackState = state;
 }
Esempio n. 35
0
 private void Awake()
 {
     this._transform = this.GetComponent<Transform>();
     this._attackState = AttackState.NotAtacks;
 }
Esempio n. 36
0
 public void Cancel()
 {
     Destroy(currentMove.gameObject);
     this.state = AttackState.None;
 }
Esempio n. 37
0
        static AttackState PSInit()
        {
            // Display Loading Message
            Console.ForegroundColor = PSColors.logoText;
            Random random     = new Random();
            int    pspLogoInt = random.Next(Strings.psaLogos.Count);

            Console.WriteLine(Strings.psaLogos[pspLogoInt]);
            Console.WriteLine("PS>Attack is loading...");

            // create attackState
            AttackState attackState = new AttackState();

            attackState.cursorPos = Display.createPrompt(attackState).Length;

            // Decrypt modules
            Assembly assembly = Assembly.GetExecutingAssembly();

            string[] resources = assembly.GetManifestResourceNames();
            foreach (string resource in resources)
            {
                if (resource.Contains(".enc"))
                {
                    string fileName    = resource.Replace("PSAttack.Modules.", "").Replace(".ps1.enc", "");
                    string decFilename = CryptoUtils.DecryptString(fileName);
                    Console.ForegroundColor = PSColors.loadingText;
                    Console.WriteLine("Decrypting: " + decFilename);
                    Stream moduleStream = assembly.GetManifestResourceStream(resource);
                    PSAUtils.ImportModules(attackState, moduleStream);
                }
            }
            // Setup PS env
            attackState.cmd = "set-executionpolicy bypass -Scope process -Force";
            Processing.PSExec(attackState);

            // check for admin
            Boolean isAdmin = false;

            if (new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator))
            {
                isAdmin = true;
                System.Diagnostics.Process.EnterDebugMode();
            }
            // setup debug variable
            String debugCmd = "$debug = @{'.NET'='" + System.Environment.Version + "';'isAdmin'='" + isAdmin + "'}";

            attackState.cmd = debugCmd;
            Processing.PSExec(attackState);

            // Setup Console
            Console.Title           = Strings.windowTitle;
            Console.BufferHeight    = Int16.MaxValue - 10;
            Console.BackgroundColor = PSColors.background;
            Console.Clear();

            // Display alpha warning
            //Console.ForegroundColor = PSColors.errorText;
            //Console.WriteLine(Strings.warning);

            // display intro text
            Console.ForegroundColor = PSColors.introText;
            string buildString;
            string attackDate = new StreamReader(assembly.GetManifestResourceStream("PSAttack.Resources.attackDate.txt")).ReadToEnd();

            if (attackDate.Length > 12)
            {
                buildString = "It was custom made by the PS>Attack Build Tool on " + attackDate + "\n";
            }
            else
            {
                string buildDate = new StreamReader(assembly.GetManifestResourceStream("PSAttack.Resources.BuildDate.txt")).ReadToEnd();
                buildString = "It was built on " + buildDate + "\nIf you'd like a version of PS>Attack thats even harder for AV \nto detect checkout http://github.com/jaredhaight/PSAttackBuildTool \n";
            }
            Console.WriteLine(Strings.welcomeMessage, Strings.version, buildString);
            // Display Prompt
            attackState.ClearLoop();
            attackState.ClearIO();
            Display.printPrompt(attackState);

            return(attackState);
        }
Esempio n. 38
0
        public override void handleInput(Input.InputState inputState)
        {
            if( currentState == State.Attacking )
                return;

            if (currentState == State.Neutral && (inputState.IsNewButtonPress(Buttons.A) || inputState.IsNewKeyPress(Keys.Space)))
            {
                currentState = State.Attacking;
                attackState = AttackState.Diagonal;
                velocity = Vector2.Zero;
                stateTimer = 0;
                return;
            }

            if (currentState == State.Neutral)
            {
                velocity = inputState.currentGamePadState.ThumbSticks.Left;
                velocity.Y *= -1f;
                acceleration = Vector2.Zero;
            }
            else
            {
                acceleration = inputState.currentGamePadState.ThumbSticks.Left * 0.1f;
                acceleration.Y *= -1f;
                return;
            }

            if (velocity.X < 0f && Math.Abs(velocity.X) > Math.Abs(velocity.Y) )
            {
                currentSourceRect = WalkingLeft;
                faceDir = FaceDirection.Left;
            }
            else if (velocity.X > 0f && Math.Abs(velocity.X) > Math.Abs(velocity.Y))
            {
                currentSourceRect = WalkingRight;
                faceDir = FaceDirection.Right;
            }
            else if (velocity.Y < 0f )
            {
                currentSourceRect = WalkingUp;
                faceDir = FaceDirection.Up;
            }
            else if (velocity.Y > 0f)
            {
                currentSourceRect = WalkingDown;
                faceDir = FaceDirection.Down;
            }

            if (Keyboard.GetState().GetPressedKeys().Length > 0)
            {
                velocity = Vector2.Zero;

                if( inputState.currentKeyboardState.IsKeyDown(Keys.W) )
                {
                    currentSourceRect = WalkingUp;
                    faceDir = FaceDirection.Up;
                    velocity.Y = -1;
                }

                if (inputState.currentKeyboardState.IsKeyDown(Keys.A))
                {
                    currentSourceRect = WalkingLeft;
                    faceDir = FaceDirection.Left;
                    velocity.X = -1;
                }

                if (inputState.currentKeyboardState.IsKeyDown(Keys.S))
                {
                    currentSourceRect = WalkingDown;
                    faceDir = FaceDirection.Down;
                    velocity.Y = 1;
                }

                if (inputState.currentKeyboardState.IsKeyDown(Keys.D))
                {
                    currentSourceRect = WalkingRight;
                    faceDir = FaceDirection.Right;
                    velocity.X = 1;
                }

                if (velocity != Vector2.Zero)
                    velocity.Normalize();
            }

            //velocity.Normalize();
            velocity *= maxSpeed;

            animSpeed = velocity.Length() / 18f;
        }
Esempio n. 39
0
 //get all of the players
 public void GetAllPlayers()
 {
     players.AddRange(GameObject.FindGameObjectsWithTag("Player"));
     numOfEnemy = players.Count;
     currState  = AttackState.GetEnemyTeam;
 }
Esempio n. 40
0
        public override void Update(GameTime gameTime)
        {
            switch (state)
            {
                case AttackState.Ready:
                    break;
                case AttackState.Charging:
                    chargeTime += gameTime.ElapsedGameTime;
                    timeSinceSwap += gameTime.ElapsedGameTime;

                    //Periodically swap arm position
                    if (timeSinceSwap > SWAP_TIME)
                    {
                        attacker.SwapArmPosition();
                        timeSinceSwap = TimeSpan.Zero;
                    }

                    if (attacker.GetLinearVelocity().X > MOVEMENT_TOLERANCE || attacker.GetLinearVelocity().Y > MOVEMENT_TOLERANCE)
                        state = AttackState.Ready;
                    break;
                case AttackState.Firing:
                    foreach (var player in affectedPlayers)
                    {
                        player.damage += damage * (float)gameTime.ElapsedGameTime.TotalSeconds * (float)(Math.Min(chargeTime.TotalSeconds, 10)) / 2.0f;
                        //wrkVect.X = (direction == Direction.Right ? 1 : -1) * PUSH_STRENGTH * (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                        //wrkVect.Y = Player.RNG.Next(-JERK_QTY, JERK_QTY);
                        wrkVect.X = Player.RNG.Next(-(int)(JERK_QTY * player.damageMultipler), (int)(JERK_QTY * player.damageMultipler));
                        wrkVect.Y = Player.RNG.Next(-(int)(JERK_QTY * player.damageMultipler), 0);
                        player.ApplyForce(wrkVect);
                        //player.stunTimer += TimeSpan.FromMilliseconds(250 * gameTime.ElapsedGameTime.TotalSeconds);
                    }

                    attackBody.SetTransform(attackBody.Position + new Vector2((direction == Direction.Right ? ATTACK_SPEED : -ATTACK_SPEED), 0) * (float)gameTime.ElapsedGameTime.TotalSeconds, 0);

                    timeAlive += gameTime.ElapsedGameTime;

                    ParticleEmitter.GenerateExplosion(attackBody.Position * PPM, new Vector2(attacker.isFlipped ? -1 : 1, 1), Color.Red);

                    if (timeAlive > lifeSpan)
                    {
                        End();
                    }
                    break;
                default:
                    break;
            }
        }
    private void ConstructFSM()
    {
        //Get the list of points
        //   pointList = GameObject.FindGameObjectsWithTag("WandarPoint");
        var pointList = gameObject.transform.Cast<Transform>().Where(c => c.gameObject.tag == "WandarPoint").Select(c => c.gameObject).ToArray();

        Transform[] waypoints = new Transform[pointList.Length];
        int i = 0;

        foreach (GameObject obj in pointList)
        {
            obj.GetComponent<Transform>().position = transform.position + new Vector3(Random.onUnitSphere.x * 5,
                                                                 Random.onUnitSphere.y * 5, Random.onUnitSphere.z * 5);
            waypoints[i] = obj.transform;
            //	waypoints[i].position = new Vector3(Random.insideUnitSphere.x * 5,
            //	                                    Random.insideUnitSphere.z * 5, Random.insideUnitSphere.z * 5);

            i++;
        }

        PatrolState patrol = new PatrolState(waypoints);
        patrol.AddTransition(FSMTransition.PlayerSeen, StateID.Chasing);
        patrol.AddTransition(FSMTransition.NoHealth, StateID.Dead);
        patrol.SetStateDistances(chaseStartDist, attackStartDist);
        patrol.SetSpeed(speed / 2, rotationSpeed / 2);
        patrol.SetBounds(patrolBounds.x, patrolBounds.y, patrolBounds.z);

        ChaseState chase = new ChaseState(waypoints);
        chase.AddTransition(FSMTransition.PlayerLost, StateID.Patrolling);
        chase.AddTransition(FSMTransition.PlayerReached, StateID.Attacking);
        chase.AddTransition(FSMTransition.NoHealth, StateID.Dead);
        chase.SetStateDistances(chaseStartDist, attackStartDist);
        chase.SetSpeed(speed, rotationSpeed);

        AttackState attack = new AttackState(waypoints);
        attack.AddTransition(FSMTransition.PlayerLost, StateID.Patrolling);
        attack.AddTransition(FSMTransition.PlayerSeen, StateID.Chasing);
        attack.AddTransition(FSMTransition.NoHealth, StateID.Dead);
        attack.SetStateDistances(chaseStartDist, attackStartDist);
        attack.SetSpeed(speed, rotationSpeed);
        attack.kamikaze = this.kamikaze;

        DeadState dead = new DeadState();
        dead.AddTransition(FSMTransition.NoHealth, StateID.Dead);

        AddFSMState(patrol);
        AddFSMState(chase);
        AddFSMState(attack);
        AddFSMState(dead);

        //Start patrolling at given points
        patrol.FindNextPoint();
    }
Esempio n. 42
0
 //constructor
 private AttackState()
 {
     instance = this;
 }
Esempio n. 43
0
 public override void Attack()
 {
     base.Attack();
     currentState = new AttackState(details);
     currentState.Attack();
 }
Esempio n. 44
0
    /// <summary>
    /// Get the various Components.
    /// Create the possible States.</summary>
    public virtual void Awake()
    {
        // Get the necessary Components
        _navMeshAgent = GetComponent<NavMeshAgent>();
        _inventory = GetComponent<Inventory>();

        // Initialize necessary properties
        _enemies = new List<Character>();
        _interactingCharacters = new List<Character>();

        // Initialize the Stats
        Stats = Instantiate(_stats);
        Stats.Character = this;

        // Initialize the States
        _idleState = new IdleState(this);
        _alertState = new AlertState(this);
        _chaseState = new ChaseState(this);
        _attackState = new AttackState(this);
        _dyingState = new DyingState(this);
        _moveState = new MoveState(this);
    }
Esempio n. 45
0
 public virtual void InterruptAttack()
 {
     StopCoroutine("AttackCoroutine");
     StopCoroutine("ImpulsesCoroutine");
     curAttackState = AttackState.Normal;
 }
Esempio n. 46
0
 public void SweepAttack()
 {
     time        = 0;
     state       = AttackState.SWEEP;
     splineStart = transform.position;
 }
Esempio n. 47
0
 protected override void ApplyEffectsCore(AttackState state, TagCollection target)
 {
     target.AddTag(Tag, ConflictResolution);
 }
Esempio n. 48
0
	void Update(){
		//when click on an enemy
		if (isLockingTarget == false && Input.GetMouseButtonDown (0) && state != PlayerState.Death) {
			//use a ray to detect whether the click is above an enemy
			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			RaycastHit hitInfo;
			bool isCollider = Physics.Raycast(ray, out hitInfo);

			//is collider and get the enemy
			if(isCollider && hitInfo.collider.tag == "Enemy"){
				//when we clicked on an enemy
				targetNormalAttack = hitInfo.collider.transform;
				//normal attack state
				state = PlayerState.NormalAttack;
				attackTimer = 0;
				showEffect = false;
			}
			//click on anything else(not enemy)
			else {
				state = PlayerState.ControlWalk;
				targetNormalAttack = null;
			}
		}

		if (state == PlayerState.NormalAttack) {
			//if the enemy is dead or not exist
			if(targetNormalAttack == null){
				state = PlayerState.ControlWalk;
			} else {
			float distance = Vector3.Distance(transform.position, targetNormalAttack.position);
			if(distance <= minDistance){
				transform.LookAt(targetNormalAttack.position);
				//the enemy is in the attack distance
				//do the attack
				attackState = AttackState.Attack;
				attackTimer += Time.deltaTime;
				animation.CrossFade(animationNow);
				//timer is more than the normal attack time
				if(attackTimer >= timeNormalAttack){
					animationNow = animationIdle;
					//make sure only show one time effect
					if(showEffect == false){
						showEffect = true;
						//show the effect
						GameObject.Instantiate(effect, targetNormalAttack.position,Quaternion.identity);
						targetNormalAttack.GetComponent<WolfBaby>().TakeDamge(normalAttack);
					}
				}
				if(attackTimer >= (1f/rateNormalAttack))
				{//end the timer,attack again
					attackTimer = 0;
					showEffect = false;
					animationNow = animationNormalAttack;
				}
			} 
			else {
				//the enemy is not in the range
				//go towards to the enemy and then do the attack
				attackState = AttackState.Moving;
				walk.SimpleMove(targetNormalAttack.position);
				//show the aimation
			}
			}
		} else if(state == PlayerState.Death){
			animation.CrossFade("Sword-Death");

		}

		if(isLockingTarget && Input.GetMouseButtonDown(0)){
			OnLockTarget();
		}
	}
 /// <summary>
 /// 获取状态
 /// </summary>
 /// <param name="AIState"></param>
 /// <returns></returns>
 private StateBase GetState(AIStateType AIState)
 {
     if (this.m_StateDic.ContainsKey(AIState))
     {
         return this.m_StateDic[AIState];
     }
     StateBase state;
     switch (AIState)
     {
         case AIStateType.Attack:
             state = new AttackState(this.m_ActorBev,this.m_ActorAI);
             break;
         case AIStateType.Dead:
             state = new DeadState(this.m_ActorBev, this.m_ActorAI);
             break;
         case AIStateType.Hurt:
             state = new HurtState(this.m_ActorBev, this.m_ActorAI);
             break;
         case AIStateType.Idle:
             state = new IdleState(this.m_ActorBev, this.m_ActorAI);
             break;
         default: Debug.Log(AIState.ToString() + " not exsit "); return null;
     }
     this.m_StateDic.Add(AIState, state);
     return state;
 }
Esempio n. 50
0
    public bool Invocate(ManageDungeon dun)
    {
        if (IsInvocation == false)
        {
            return(false);
        }
        IsActive     = true;
        IsInvocation = false;
        int bresult;

        //オプションによるトラップ回避
        float t = 0;

        foreach (BaseOption o in Target.Options)
        {
            t += o.DexTrap();
        }

        if (CommonFunction.IsRandom(t) == true)
        {
            DisplayInformation.Info.AddMessage(CommonConst.Message.DexTrap);
            Target = null;
            return(false);
        }

        //スコア値の更新
        DungeonHistoryInformation.Info.iTrapInvokeCount++;

        //サウンドを鳴らす
        if (Target.Type == ObjectType.Player)
        {
            VoiceInformation.Voice.Play(PlayerInformation.Info.PType, VoiceInformation.Voice.PlayRandomDefence());
        }

        bool result = false;

        //効果発動
        switch (TType)
        {
        case TrapType.Bomb:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Bomb);

            //エフェクトの発動
            EffectBigBang.CreateObject(this).Play();

            //ダメージ処理
            int         damage  = Mathf.CeilToInt(Target.CurrentHp / PerPlayerDamage);
            AttackState atState = Target.AddDamage(damage);

            //プレイヤーが死亡したら
            if (atState == AttackState.Death)
            {
                DisplayInformation.Info.AddMessage(
                    Target.GetMessageDeath(Target.HaveExperience));

                ScoreInformation.Info.CauseDeath =
                    string.Format(CommonConst.DeathMessage.Trap, DisplayNameNormal);
                ScoreInformation.Info.CauseDeathType = DeathCouseType.Trap;

                Target.Death();
                Target.DeathAction(dun);
            }


            //ダメージエフェクト
            EffectDamage d = EffectDamage.CreateObject(Target);
            d.SetText(damage.ToString(), AttackState.Hit);
            d.Play();

            //ヒットメッセージ
            DisplayInformation.Info.AddMessage(
                Target.GetMessageAttackHit(damage));

            //周辺キャラのダメージ処理
            dun.SetUpCharacterMap();
            List <BaseCharacter> list = dun.GetNearCharacters(this.CurrentPoint, 1);
            foreach (BaseCharacter c in list)
            {
                atState = c.AddDamage(CommonNumber);
                EffectDamage d2 = EffectDamage.CreateObject(c);
                d2.SetText(CommonNumber.ToString(), AttackState.Hit);
                d2.Play();

                //対象が死亡したら
                if (atState == AttackState.Death)
                {
                    DisplayInformation.Info.AddMessage(
                        string.Format(CommonConst.Message.DeathCommon, c.DisplayNameInMessage));

                    c.Death();
                    c.DeathAction(dun);
                }
            }
            result = true;
            break;

        case TrapType.ColorMonitor:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            //エフェクトの発動
            EffectColorMonitor.CreateObject(this).Play();

            //効果
            bresult = Target.AddStateAbnormal((int)StateAbnormal.StiffShoulder);
            //対象が異常になったらメッセージを表示
            if (bresult != 0)
            {
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.StiffShoulder, Target));
            }
            result = true;
            break;

        case TrapType.Cyclone:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Cyclone);

            //エフェクトの発動
            EffectCyclone.CreateObject(Target).Play();

            //メッセージの出力
            DisplayInformation.Info.AddMessage(
                string.Format(CommonConst.Message.TrapCyclone2, Target.DisplayNameInMessage));

            //効果

            result = true;
            break;

        case TrapType.Electric:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.ElectricTrap);

            //エフェクトの発動
            EffectThunder.CreateObject(Target).Play();

            BaseItem[] equips = PlayerCharacter.ItemList.FindAll(i => i.IsEquip == true).ToArray();

            if (equips.Length > 0)
            {
                foreach (BaseItem i in equips)
                {
                    i.ForceRemoveEquip(Target);
                }

                DisplayInformation.Info.AddMessage(
                    string.Format(CommonConst.Message.TrapEquipRemove, Target.DisplayNameInMessage));
            }

            result = true;
            break;

        case TrapType.Mud:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            //エフェクトの発動
            EffectBadSmoke.CreateObject(Target).Play();

            //効果
            bresult = Target.AddStateAbnormal((int)StateAbnormal.Slow);
            //対象が異常になったらメッセージを表示
            if (bresult != 0)
            {
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.Slow, Target));
            }
            result = true;
            break;

        case TrapType.Palalysis:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            //エフェクトの発動
            EffectBadSmoke.CreateObject(Target).Play();

            //効果
            bresult = Target.AddStateAbnormal((int)StateAbnormal.Palalysis);
            //対象が異常になったらメッセージを表示
            if (bresult != 0)
            {
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.Palalysis, Target));
            }
            result = true;
            break;

        case TrapType.Photo:
            if (Target.Type == ObjectType.Player)
            {
                //サウンドを鳴らす
                SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

                //エフェクトの発動
                EffectBadSmoke.CreateObject(Target).Play();

                //メッセージの出力
                DisplayInformation.Info.AddMessage(
                    string.Format(CommonConst.Message.TrapCroquette2, Target.DisplayNameInMessage));

                ((PlayerCharacter)Target).ReduceSatiety(CommonNumber);
                result = true;
            }
            break;

        case TrapType.Poison:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            //エフェクトの発動
            EffectBadSmoke.CreateObject(Target).Play();

            //効果
            bresult = Target.AddStateAbnormal((int)StateAbnormal.Poison);
            //対象が異常になったらメッセージを表示
            if (bresult != 0)
            {
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.Poison, Target));
            }

            result = true;
            break;

        case TrapType.DeadlyPoison:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            //エフェクトの発動
            EffectBadSmoke.CreateObject(Target).Play();

            //効果
            bresult = Target.AddStateAbnormal((int)StateAbnormal.DeadlyPoison);
            //対象が異常になったらメッセージを表示
            if (bresult != 0)
            {
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.DeadlyPoison, Target));
            }

            result = true;
            break;

        case TrapType.Rotation:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Rotation);

            //エフェクトの発動
            EffectRotation.CreateObject(Target).Play();

            //効果
            bresult = Target.AddStateAbnormal((int)StateAbnormal.Confusion);
            //対象が異常になったらメッセージを表示
            if (bresult != 0)
            {
                EffectSmoke.CreateObject(Target);
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.Confusion, Target));
            }


            result = true;
            break;

        case TrapType.SandStorm:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Cyclone);

            //エフェクトの発動
            EffectSandStorm.CreateObject(Target).Play();

            //効果
            bresult = Target.AddStateAbnormal((int)StateAbnormal.Dark);
            //対象が異常になったらメッセージを表示
            if (bresult != 0)
            {
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.Dark, Target));
            }
            result = true;
            break;

        case TrapType.Song:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            //エフェクトの発動
            EffectBadSmoke.CreateObject(Target).Play();

            //効果
            bresult = Target.AddStateAbnormal((int)StateAbnormal.Sleep);
            //対象が異常になったらメッセージを表示
            if (bresult != 0)
            {
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.Sleep, Target));
            }
            result = true;
            break;

        case TrapType.Summon:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Summon);

            //エフェクトの発動
            EffectSummon.CreateObject(Target).Play();

            int cnt = CommonFunction.ConvergenceRandom(CountStart, ProbStart, ProbReduce);

            for (int i = 0; i < cnt; i++)
            {
                dun.SetUpCharacterMap();
                //敵の出現地点を取得
                MapPoint mp = dun.GetCharacterEmptyTarget(Target.CurrentPoint);
                if (CommonFunction.IsNull(mp) == true)
                {
                    break;
                }

                int  enemytype           = TableEnemyMap.GetValue(dun.DungeonObjNo, DisplayInformation.Info.Floor);
                uint rand                = CommonFunction.GetRandomUInt32();
                BaseEnemyCharacter enemy = TableEnemyIncidence.GetEnemy(enemytype, rand, DisplayInformation.Info.Floor);

                enemy.SetCharacterDisplayObject(mp.X, mp.Y);
                dun.AddNewCharacter(enemy);
            }
            DisplayInformation.Info.AddMessage(
                CommonConst.Message.TrapSummon);

            result = true;
            break;

        case TrapType.TheFly:

            if (Target.Type == ObjectType.Player)
            {
                //サウンドを鳴らす
                SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

                //エフェクトの発動
                EffectBadSmoke.CreateObject(Target).Play();

                BaseItem[] foods = PlayerCharacter.ItemList.FindAll(i => i.IType == ItemType.Food).ToArray();

                if (foods.Length > 0)
                {
                    foreach (BaseItem i in foods)
                    {
                        PlayerCharacter.RemoveItem(i);
                        ((PlayerCharacter)Target).AddItem(TableFood.GetItem(CommonConst.ObjNo.FlyCroquette), i.SortNo);
                    }

                    //メッセージの出力
                    DisplayInformation.Info.AddMessage(
                        string.Format(CommonConst.Message.TrapFly2));
                }

                result = true;
            }
            break;

        case TrapType.WaterBucket:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.BucketFall);

            //エフェクトの発動
            EffectWaterBucket.CreateObject(Target).Play();

            //効果
            bresult = Target.AddStateAbnormal((int)StateAbnormal.Reticent);
            //対象が異常になったらメッセージを表示
            if (bresult != 0)
            {
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.Reticent, Target));
            }

            result = true;
            break;

        //花粉
        case TrapType.Pollen:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            //エフェクトの発動
            EffectSmoke d3 = EffectSmoke.CreateObject(Target);
            d3.SetColor(Color.yellow);
            d3.Play();

            //力減少
            Target.ReducePower((ushort)CommonNumber);

            //メッセージの出力
            DisplayInformation.Info.AddMessage(
                string.Format(CommonConst.Message.TrapPllen2, Target.DisplayNameInMessage));

            result = true;
            break;

        case TrapType.Ember:

            //ダメージ処理
            int damage2 = CommonNumber;

            //通常ダメージの場合
            if (CommonFunction.HasOptionType(this.Options, OptionType.ReverceDamage) == false)
            {
                AttackState atState2 = Target.AddDamage(damage2);

                //ダメージエフェクト
                EffectDamage d4 = EffectDamage.CreateObject(Target);
                d4.SetText(damage2.ToString(), AttackState.Hit);
                d4.Play();

                DisplayInformation.Info.AddMessage(
                    string.Format(CommonConst.Message.TrapDamage, Target.DisplayNameInMessage, this.DisplayNameInMessage, damage2));

                //対象が死亡したら
                if (atState2 == AttackState.Death)
                {
                    DisplayInformation.Info.AddMessage(
                        Target.GetMessageDeath(Target.HaveExperience));

                    if (Target.Type == ObjectType.Player)
                    {
                        ScoreInformation.Info.CauseDeath =
                            string.Format(CommonConst.DeathMessage.Trap, DisplayNameNormal);
                        ScoreInformation.Info.CauseDeathType = DeathCouseType.Trap;
                    }
                    Target.Death();
                    Target.DeathAction(dun);
                }
            }
            //反転回復の場合
            else
            {
                Target.RecoverHp(damage2);

                //ダメージエフェクト
                EffectDamage d4 = EffectDamage.CreateObject(Target);
                d4.SetText(damage2.ToString(), AttackState.Heal);
                d4.Play();


                DisplayInformation.Info.AddMessage(
                    string.Format(CommonConst.Message.TrapRecover, Target.DisplayNameInMessage, this.DisplayNameInMessage, damage2));
            }
            break;
        }
        Target = null;

        return(result);
    }
Esempio n. 51
0
        public override void Start(Vector2 _pos, ControlSystem.Direction _dir)
        {
            switch (state)
            {
                case AttackState.Ready:
                    //attacker.stunTimer += TimeSpan.FromMilliseconds(50);
                    position = _pos;
                    offset = _pos - attacker.GetPosition();
                    direction = _dir;
                    state = AttackState.Charging;
                    timeAlive = TimeSpan.Zero;
                    chargeTime = TimeSpan.Zero;
                    break;
                case AttackState.Charging:
                    if (!attacker.isStunned)
                    {
                        state = AttackState.Firing;

                        Sound.QueueEffect(EffectType.Crit);

                        size = new Vector2(SizeFromCharge(), SizeFromCharge());
                        moveStrength = 10f;

                        attackBody = BodyFactory.CreateRectangle(world, size.X / PPM, size.Y / PPM, 5, this);
                        attackBody.Position = (attacker.GetPosition() + offset) / PPM;
                        attackBody.CollisionCategories = Category.Cat3;
                        attackBody.CollidesWith = Category.Cat2;
                        attackBody.OnCollision += attackOnCollision;
                        attackBody.OnSeparation += attackOnSeperation;
                        attackBody.IsSensor = true;
                    }
                    break;
                case AttackState.Firing:
                    break;
                default:
                    break;
            }
        }
Esempio n. 52
0
 public void Idle()
 {
     time  = 0;
     state = AttackState.IDLE;
 }
Esempio n. 53
0
 public abstract void UseAbility(AttackState attack);
Esempio n. 54
0
        private void ComputeAttackData(int BAC)
        {
            RainbowLib.BAC.Script currentScript = bac.Scripts.Where(x => x.Index == ScriptIndex).FirstOrDefault();
            if (currentScript == null)
                return;
            var ScriptOffset = BAC + Util.Memory.ReadInt((int)((BAC + Util.Memory.ReadInt((int)BAC + 0x14)) + 4 * ScriptIndex));
            var ScriptCommandListCount = Util.Memory.ReadShort((int)ScriptOffset + 0x12);
            var b = (int)ScriptOffset + 0x18;
            var commandStarts = new List<ushort>();
            var speeds = new List<float>();
            AttackRange = 0;

            var FallBackRange = 0.0f;
            var useFallBack = true;
            foreach (HitboxCommand hitboxCommand in currentScript.CommandLists[(int)CommandListType.HITBOX])
            {

                var type = hitboxCommand.Type;

                var hitlevel = hitboxCommand.HitLevel;
                var flags = hitboxCommand.HitFlags;

                var xoff = hitboxCommand.X;
                var yoff = hitboxCommand.Y;

                var sizex = hitboxCommand.Width;
                var sizey = hitboxCommand.Height;
                var range = xoff + sizex * 2;
                if (type == 0)
                {
                    FallBackRange = range;
                    continue;
                }
                var attach = hitboxCommand.AttachPoint;

                if ((attach) != 0)
                {
                    //Console.WriteLine("WARNING ATTACH " + ScriptName);
                }
                else
                    useFallBack = false;

                AttackRange = Math.Max(AttackRange, range);
                try
                {
                    ScriptFrameHitboxStart = Math.Min(ScriptFrameHitboxStart, Tick2Frame[hitboxCommand.StartFrame]);
                    ScriptFrameHitboxEnd = Math.Max(ScriptFrameHitboxEnd, Tick2Frame[hitboxCommand.EndFrame]);
                }
                catch (Exception)
                {

                }
                if (type.HasFlag(HitboxCommand.HitboxType.GRAB) || flags.HasFlag(HitboxCommand.FlagsType.UNBLOCKABLE))
                {
                    if (!ScriptName.Contains("BALCERONA"))
                    {
                        AState = AttackState.Throw;
                        continue;
                    }
                }


                if (hitlevel == HitboxCommand.HitLevelType.MID)
                    AState = AttackState.Mid;
                if (hitlevel == HitboxCommand.HitLevelType.OVERHEAD)
                    AState = AttackState.Overhead;
                if (hitlevel == HitboxCommand.HitLevelType.LOW)
                    AState = AttackState.Low;
                if (hitlevel == HitboxCommand.HitLevelType.UNBLOCKABLE)
                    AState = AttackState.Throw;
            }
            if (useFallBack == true)
                AttackRange = FallBackRange;

        }
Esempio n. 55
0
        public override void updateHorizontal(float dt)
        {
            if( currentState == State.Neutral )
                acceleration = Vector2.Zero;

            base.updateHorizontal(dt);

            if (currentState == State.Attacking)
            {
                stateTimer += stateTimerSpeed * dt;
                if (attackState == AttackState.Diagonal)
                {
                    if (stateTimer >= 1f)
                    {
                        stateTimer = 0f;
                        attackState = AttackState.Straight;
                    }
                    else
                    {
                        switch (faceDir)
                        {
                            case FaceDirection.Up:
                                attackRect.x = (int)position.X + 4 * 6;
                                attackRect.y = (int)position.Y - 4 * 6;
                                attackSourceRect = SwordUp[0];
                                break;

                            case FaceDirection.Right:
                                attackRect.x = (int)position.X + 4 * 4;
                                attackRect.y = (int)position.Y + 4 * 6;
                                attackSourceRect = SwordRight[0];
                                break;

                            case FaceDirection.Down:
                                attackRect.x = (int)position.X - 4 * 6;
                                attackRect.y = (int)position.Y + 4 * 4;
                                attackSourceRect = SwordDown[0];
                                break;

                            case FaceDirection.Left:
                                attackRect.x = (int)position.X - 4 * 4;
                                attackRect.y = (int)position.Y - 4 * 6;
                                attackSourceRect = SwordLeft[0];
                                break;

                            default:
                                currentState = State.Neutral;
                                break;
                        }
                    }
                }

                if (attackState == AttackState.Straight)
                {
                    if (stateTimer >= 1f)
                    {
                        stateTimer = 0f;
                        currentState = State.Neutral;
                    }
                    else
                    {
                        switch (faceDir)
                        {
                            case FaceDirection.Up:
                                attackRect.x = (int)position.X;
                                attackRect.y = (int)position.Y - 4 * 8;
                                attackSourceRect = SwordUp[1];
                                break;

                            case FaceDirection.Right:
                                attackRect.x = (int)position.X + 4 * 6;
                                attackRect.y = (int)position.Y;
                                attackSourceRect = SwordRight[1];
                                break;

                            case FaceDirection.Down:
                                attackRect.x = (int)position.X;
                                attackRect.y = (int)position.Y + 4 * 8;
                                attackSourceRect = SwordDown[1];
                                break;

                            case FaceDirection.Left:
                                attackRect.x = (int)position.X - 4 * 6;
                                attackRect.y = (int)position.Y + 4;
                                attackSourceRect = SwordLeft[1];
                                break;

                            default:
                                currentState = State.Neutral;
                                break;
                        }
                    }
                }
            }

            if (Math.Abs(velocity.X * velocity.X + velocity.Y * velocity.Y) <= 0.000001f)
                return;

            animTimer += animSpeed * dt;
            if (animTimer >= 1f)
            {
                animTimer = 0f;
                currentAnim = (currentAnim + 1) % animCount;
            }
        }
Esempio n. 56
0
    void AddInputMotionNormal()
    {
        if (input.right && state == CharacterState.Normal)
        {
            facingDir = 1;
            if (onGround)
            {
                if (velocity.x < 0f)
                {
                    if (velocity.x < maxRunSpeed * 0.9f)
                    {
                        EffectsController.CreateTurnAroundPuff(transform.position, 1f);
                    }
                    velocity.x = 0f;
                }
                velocity.x += t * runAccel;
            }
            else
            {
                velocity.x += t * airAccel;
            }
            if (velocity.x > maxRunSpeed)
            {
                velocity.x = maxRunSpeed;
            }
        }
        else if (input.left && state == CharacterState.Normal)
        {
            facingDir = -1;
            if (onGround)
            {
                if (velocity.x > 0f)
                {
                    if (velocity.x > -maxRunSpeed * 0.9f)
                    {
                        EffectsController.CreateTurnAroundPuff(transform.position, -1f);
                    }
                    velocity.x = 0f;
                }
                velocity.x -= t * runAccel;
            }
            else
            {
                velocity.x -= t * airAccel;
            }
            if (velocity.x < -maxRunSpeed)
            {
                velocity.x = -maxRunSpeed;
            }
        }
        else
        {
            if (onGround)
            {
                if (velocity.x > 0)
                {
                    velocity.x -= t * runAccel;
                    if (velocity.x < 0)
                    {
                        velocity.x = 0;
                    }
                }
                else if (velocity.x < 0)
                {
                    velocity.x += t * runAccel;
                    if (velocity.x > 0)
                    {
                        velocity.x = 0;
                    }
                }
            }
        }

        if (input.xButton)
        {
            if (state == CharacterState.Normal)
            {
                state = CharacterState.Attacking;
                if (attackState == AttackState.Idle)
                {
                    attackState = AttackState.Charging;
                    SoundController.PlaySoundEffect("BatChargeUp", 0.5f, transform.position);
                    attackChargeCounter = 0f;
                }
            }

            if (attackState == AttackState.Charging)
            {
                if (input.right)
                {
                    facingDir = 1;
                }
                else if (input.left)
                {
                    facingDir = -1;
                }
            }
        }

        if (input.bButton)
        {
            if (state == CharacterState.Normal && !input.wasBButton)
            {
                StartTongueAttack();
            }
        }

        if (input.aButton && !input.down && (jumpCooldownLeft <= 0f || (!input.wasAButton && state != CharacterState.Attacking)))
        {
            if (onGround || WallSliding)
            {
                velocity.y           = jumpVel;
                gravityGraceTimeLeft = gravityGraceTime;

                if (WallSliding)
                {
                    if (WallSlideSide == EffectsController.Side.Left)
                    {
                        velocity.x = maxRunSpeed;
                    }
                    else if (WallSlideSide == EffectsController.Side.Right)
                    {
                        velocity.x = -maxRunSpeed;
                    }
                }



                //Debug.Break();
                SoundController.PlaySoundEffect("Jump", 0.4f, transform.position);
                if (WallSliding)
                {
                    EffectsController.CreateJumpPuffStraight(transform.position, WallSlideSide);
                }
                else
                {
                    EffectsController.CreateJumpPuffStraight(transform.position, EffectsController.Side.Bottom);
                }
            }
            else if (jumpGraceTimeLeft > 0f) // && (velocity.y > 0f || !input.wasAButton))
            {
                velocity.y = jumpVel;
            }
        }
    }
Esempio n. 57
0
        private void ReadBACData()
        {
            var BAC = (int)Util.Memory.ReadInt((int)Util.Memory.ReadInt(_BaseOffset + 0xB0) + 0x8);

            if (BAC != bac_off && BAC != 0)
            {
                //Gotta load BCM
                var tmpfile = File.Create(System.IO.Path.GetTempPath() + "/tmp.bac", 0x4000);
                var tmparr = Util.Memory.ReadAOB(BAC, 0xA0000);
                tmpfile.Write(tmparr, 0, tmparr.Length);
                tmpfile.Close();
                bac = BACFile.FromFilename(System.IO.Path.GetTempPath() + "/tmp.bac", bcm);
                bac_off = BAC;
            }
            //Not in a match
            if (BAC == 0)
                return;

            var BAC_data = (int)Util.Memory.ReadInt(_BaseOffset + 0xB0);
            var XChange = X;

            X = Util.Memory.ReadFloat(_BaseOffset + 0x16D0);
            Y = Util.Memory.ReadFloat(_BaseOffset + 0x74);
            XChange = XChange - X;
            XVelocity = Util.Memory.ReadFloat(_BaseOffset + 0xe0);
            if (XVelocity == 0 && XChange != 0)
            {
                XVelocity = XChange;
                //Console.WriteLine("Using {0} for XVel due to XChange", XChange);
            }
            YVelocity = Util.Memory.ReadFloat(_BaseOffset + 0xe4);
            XAcceleration = Util.Memory.ReadFloat(_BaseOffset + 0x100);
            YAcceleration = Util.Memory.ReadFloat(_BaseOffset + 0x104);

            Meter = (int)Util.Memory.ReadShort(_BaseOffset + 0x6C3A);
            Revenge = (int)Util.Memory.ReadShort(_BaseOffset + 0x6C4E);


            Flags = (StatusFlags)Util.Memory.ReadInt(_BaseOffset + 0xBC);
            LastScriptIndex = ScriptIndex;

            ScriptIndex = (int)Util.Memory.ReadInt(BAC_data + 0x18);
            LastScriptName = ScriptName;
            var script = bac.Scripts.Where(x => x.Index == ScriptIndex).FirstOrDefault();
            if (script == null)
                ScriptName = ScriptIndex.ToString();
            else
                ScriptName = script.Name;
            if (ScriptName == "")
                return;
            ScriptTickTotal = Util.Memory.ReadInt(BAC_data + 0x24) / 0x10000;
            ScriptTickHitboxStart = Util.Memory.ReadInt(BAC_data + 0x28) / 0x10000;
            ScriptTickHitboxEnd = Util.Memory.ReadInt(BAC_data + 0x2C) / 0x10000;
            ScriptTickIASA = Util.Memory.ReadInt(BAC_data + 0x30) / 0x10000;
            ScriptTick = Util.Memory.ReadInt(BAC_data + 0x3C) / 0x10000;

            ScriptSpeed = Util.Memory.ReadInt(BAC_data + 0x18 + 0xC0) / 0x10000;


            if (ScriptTickIASA == 0)
                ScriptTickIASA = ScriptTickTotal;

            ComputeTickstoFrames(BAC);
            ComputeAttackData(BAC);

            if (ScriptFrameHitboxStart != 0)
            {
                if (ScriptFrame <= ScriptFrameHitboxStart)
                {
                    State = CharState.Startup;
                    StateTimer = ScriptFrameHitboxStart - ScriptFrame;

                }
                else if (ScriptFrame <= ScriptFrameHitboxEnd)
                {
                    State = CharState.Active;
                    StateTimer = ScriptFrameHitboxEnd - ScriptFrame;
                }
                else if (ScriptFrameIASA > 0 && ScriptFrame <= ScriptFrameIASA)
                {
                    State = CharState.Recovery;
                    StateTimer = ScriptFrameIASA - ScriptFrame;
                }
                else if (ScriptFrame <= ScriptFrameTotal)
                {
                    State = CharState.Recovery;
                    StateTimer = ScriptFrameTotal - ScriptFrame;
                }
                else
                {
                    State = CharState.Neutral;
                }
            }
            else
            {
                State = CharState.Neutral;
                StateTimer = -1;
                AState = AttackState.None;
            }
        }
Esempio n. 58
0
    void RunAttack()
    {
        if (attackState == AttackState.Charging)
        {
            attackDir            = facingDir * Vector2.right;
            attackChargeCounter += t;
            if (input.up)
            {
                if (!input.left && !input.right)
                {
                    attackDir = Vector2.up;
                    //attackOffset = Vector2.up * 2f;
                }
                else if (input.left)
                {
                    attackDir = Vector2.up + Vector2.left;
                    //attackOffset = new Vector2(-1f, 2f);
                }
                else if (input.right)
                {
                    attackDir = Vector2.up + Vector2.right;
                }
            }
            else if (input.down && !OnGround)
            {
                if (!input.left && !input.right)
                {
                    attackDir = Vector2.down;
                }
                else if (input.left)
                {
                    attackDir = Vector2.down + Vector2.left;
                }
                else if (input.right)
                {
                    attackDir = Vector2.down + Vector2.right;
                }
            }
        }

        if (!input.xButton && input.wasXButton && attackState == AttackState.Charging)
        {
            attackState = AttackState.Attacking;
            SoundController.PlaySoundEffect("BatSwing", 0.4f + attackChargeM * 0.4f, transform.position);
            if (attackChargeM > 0.25f || IngestedFly)
            {
                SoundController.PlaySoundEffect("BatSwingVoice", 0.4f, transform.position);
            }
            attackTimeLeft = attackTime;
            if (attackChargeM > 0.5f)
            {
                if (attackDir == Vector2.left || attackDir == Vector2.right)
                {
                    EffectsController.CreateShingEffect(Center + (Vector3)attackDir * 3f + Vector3.up * 0.2f, attackDir);
                }
                else if (attackDir == Vector2.up)
                {
                    EffectsController.CreateShingEffect(Center + (Vector3)attackDir * 3.75f, attackDir);
                }
                else if (attackDir == Vector2.down)
                {
                    EffectsController.CreateShingEffect(Center + (Vector3)attackDir * 2.75f, attackDir);
                }
                else if (attackDir.y > 0f)
                {
                    EffectsController.CreateShingEffect(Center + (Vector3)attackDir * 2.75f, attackDir);
                }
                else
                {
                    EffectsController.CreateShingEffect(Center + (Vector3)attackDir * 2.75f, attackDir);
                }
            }
        }
        else if (attackState == AttackState.Attacking)
        {
            attackTimeLeft -= t;
            if (attackTimeLeft <= 0f)
            {
                RaycastHit2D[] hits;
                Vector2        attackOffset = Vector2.up;
                float          rangeBonus   = 0f;
                if (attackChargeM > 0.5f)
                {
                    rangeBonus = attackChargeM;
                }
                float radius = 1.25f;
                if (attackDir.y < 0f)
                {
                    radius = 1.75f;
                }
                hits = Physics2D.CircleCastAll((Vector2)transform.position + attackOffset, radius, attackDir, attackRange + rangeBonus, characterLayer);
                Debug.DrawLine(transform.position + (Vector3)attackOffset, transform.position + (Vector3)attackOffset + (Vector3)attackDir.normalized * (attackRange + rangeBonus + radius), Color.red, 1f);

                if (hits.Length > 0)
                {
                    for (int i = 0; i < hits.Length; i++)
                    {
                        var hitChar = hits[i].collider.gameObject.GetComponent <Character>();
                        if (hitChar != null && hitChar != this)
                        {
                            //Debug.Break();
                            Hit(hitChar, attackDir);
                        }
                    }
                }


                attackState           = AttackState.Recovering;
                attackRecoverTimeLeft = attackRecoverTime;
            }
        }
        else if (attackState == AttackState.Recovering)
        {
            attackRecoverTimeLeft -= t;
            if (attackRecoverTimeLeft < 0f)
            {
                attackState = AttackState.Idle;
                state       = CharacterState.Normal;
            }
        }
    }
Esempio n. 59
0
        public override Activity Tick(Actor self)
        {
            switch (stance)
            {
                case AttackState.Uninitialized:
                    GrantUpgrades(self);
                    stance = AttackState.Burrowed;
                    countdown = swallow.Info.AttackDelay;
                    burrowLocation = self.Location;
                    break;
                case AttackState.Burrowed:
                    if (--countdown > 0)
                        return this;

                    var targetLocation = target.Actor.Location;

                    // The target has moved too far away
                    if ((burrowLocation - targetLocation).Length > NearEnough)
                    {
                        RevokeUpgrades(self);
                        return NextActivity;
                    }

                    // The target reached solid ground
                    if (!positionable.CanEnterCell(targetLocation, null, false))
                    {
                        RevokeUpgrades(self);
                        return NextActivity;
                    }

                    var targets = self.World.ActorMap.GetActorsAt(targetLocation)
                        .Where(t => !t.Equals(self) && weapon.IsValidAgainst(t, self));

                    if (!targets.Any())
                    {
                        RevokeUpgrades(self);
                        return NextActivity;
                    }

                    stance = AttackState.Attacking;
                    countdown = swallow.Info.ReturnDelay;
                    sandworm.IsAttacking = true;
                    AttackTargets(self, targets);

                    break;
                case AttackState.Attacking:
                    if (--countdown > 0)
                        return this;

                    sandworm.IsAttacking = false;

                    // There is a chance that the worm would just go away after attacking
                    if (self.World.SharedRandom.Next(100) <= sandworm.Info.ChanceToDisappear)
                    {
                        self.CancelActivity();
                        self.World.AddFrameEndTask(w => self.Dispose());
                    }

                    RevokeUpgrades(self);
                    return NextActivity;
            }

            return this;
        }
Esempio n. 60
0
 private void ResetAttackState()
 {
     _inputFreeze         = false;
     spriteRenderer.color = Color.white;
     _attackState         = AttackState.Neutral;
 }