예제 #1
0
 void Attack()
 {
     if (Stunned())
     {
         return;
     }
     if (Input.GetKeyDown(Controls.player_attack1))
     {
         mgAttack.Attack(Controls.player_attack1, GetAnalogDirection());
     }
     else if (Input.GetKeyDown(Controls.player_attack2))
     {
         mgAttack.Attack(Controls.player_attack2, GetAnalogDirection());
     }
 }
예제 #2
0
    private void Summon(double deltaTime)
    {
        countTime += deltaTime;

        var canSummon = (countTime - summonSpeedSec) >= float.Epsilon;

        if (canSummon)
        {
            GameObject.Find("SoundManager").GetComponent <SEManager>().PlaySE("summon", 0.5f);
            // 最上部のモンスターを消してダメージを与える
            int totalRank = 0;
            var delaySec  = 0f;
            for (int i = 0; i < gridInfo.monsterPos.GetLength(0); i++)
            {
                var monster = gridInfo.monsterPos[i, 0];
                if (monster != null)
                {
                    totalRank += monster.GetComponent <Block>().blockData.Rank;
                    BlockLight light = monster.transform.Find("Light").GetComponent <BlockLight>();
                    Color      color = monster.GetComponent <SpriteRenderer>().color;
                    StartCoroutine(DelayMethod(delaySec, () =>
                    {
                        monster.GetComponent <SpriteRenderer>().color = new Color(color.r, color.g, color.b, 0);
                        light.Merge();
                    }));
                    delaySec += 0.1f;
                }
            }
            attackManager.Attack(totalRank);
            countTime = 0;
        }
        summonTimeText.SetText(string.Format("{0:0.0}", (summonSpeedSec - countTime)));
    }
예제 #3
0
    public override void CommandUpdate()
    {
        if (ReturnifDead())
        {
            return;
        }
        if (Vector3.Distance(transform.position, startingPoint) > leashDistance)
        {
            commandManager.commandQueue.Insert(1, Cmd_Move.New(transform.gameObject, startingPoint));
            attackManager.Target = null;
            commandManager.NextCommand();
            return;
        }

        agent.SetDestination(TargetUnit.transform.position);
        var distance = Vector3.Distance(TargetUnit.transform.position, transform.position);

        if (distance <= (attackManager.GetMinimumWeaponRange() + 1))
        {
            agent.isStopped = true;
            attackManager.Attack();
        }
        else
        {
            commandManager.animator.Play(GetComponent <UnitAnimation>().CombatWalk.name);
            agent.isStopped = false;
        }
    }
예제 #4
0
 /// <summary>
 /// 点击松开时响应
 /// </summary>
 public void OnPointerUp()
 {
     if (!coolDownTimer.IsTimeUp)
     {
         return;
     }
     isCharging = false;
     if (targetAttack.gameObject.activeInHierarchy)
     {
         targetAttack.Attack(CurrentValue);
     }
     ResetChargeValue();
 }
예제 #5
0
 void Attack()
 {
     if (_target && _targetType == TargetType.Attack)
     {
         Vector2 distance = _target.transform.position - transform.position;
         attackTime = 30;
         AttackManager.Attack(gameObject, distance.normalized * 0.1f, 10, 0.2f, _Attack, false);
         EffectManager.MoveEffect("Attack_0", transform.position + new Vector3(0, 0.15f, 0), distance.normalized);
         //向かせる
         _moveDirection = distance;
         //EffectManager.AnchoredMoveEffect("Attack_00", transform, distance.normalized);
     }
 }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        if (!buildingActive)
        {
            return;
        }

        if (buildingData.attackData != null && Target.NullTarget(target) && checkForTargets.Expired())
        {
            checkForTargets.Start(1f);
            target = Target.GetClosestTarget(this.transform.position, "Enemy", buildingData.attackData.attackRange);
            //target = Target.GetClosestTarget(this.transform.position, "Enemy");
        }

        if (buildingData.attackData != null && !Target.NullTarget(target) && attackManager.AttackReady() && workers > 0)
        {
            //Debug.Log("Shooting " + target.name);
            attackManager.Attack(target);
            AudioSource.PlayClipAtPoint(audioClip, transform.position + new Vector3(0, 35, 0), 1f);
        }
    }
예제 #7
0
        public void StartAttacking(IAttackTarget attackTarget, object locker)
        {
            IsAttacking = true;
            var attackCooldown = Convert.ToInt32(1000 / Monster.AttackSpeed);

            while (IsAttacking)
            {
                Thread.Sleep(attackCooldown);

                lock (locker)
                {
                    if (Monster.IsDead || attackTarget.IsDead)
                    {
                        break;
                    }

                    var dealtDamage = AttackManager.Attack(attackTarget);
                    if (attackTarget.IsDead)
                    {
                        break;
                    }
                }
            }
        }
예제 #8
0
 /// <summary>
 /// 攻击
 /// </summary>
 public void Attack()
 {
     attackManager.Attack(defaultStats.attackForce.GetRandomValue(), defaultStats.attackDamage.GetRandomValue(), defaultStats.attackRate.GetRandomValue());
 }
예제 #9
0
 public void AttackPressed(float timeReleased)
 {
     PlayerAttack.Attack(timeReleased);
 }
예제 #10
0
        public static void Handle()
        {
            KeyInfo = Console.ReadKey(true);
            switch (KeyInfo.Key)
            {
            case ConsoleKey.F1:
                new Menu.Message().Run();
                Console.Clear();
                State.Current.Info.Draw();
                State.Current.Display.Draw();
                State.Current.Chat.DrawTitleCustom();
                break;

            case ConsoleKey.UpArrow:
            case ConsoleKey.DownArrow:
            case ConsoleKey.LeftArrow:
            case ConsoleKey.RightArrow:
                TimeManager.Steps--;
                State.Current.GameField.MoveObjects();
                State.Current.Chat.MessageMin(new DrawerLine("Steps left : " + TimeManager.Steps.ToString(), ConsoleColor.DarkYellow));
                State.Current.Hero.Position = State.Current.GameField.Move(State.Current.Hero.Position, KeyInfo.Key);
                State.Current.GameField.Activate(State.Current.Hero.Position);
                if (State.Random.Next(50) == 0)
                {
                    State.Current.GameField.DropItem();
                }
                if (State.Random.Next(20) == 0)
                {
                    State.Current.GameField.DropUsefullItem();
                }
                break;

            case ConsoleKey.A:
                AttackManager.Attack();
                break;

            case ConsoleKey.Q:
                AttackManager.Attack(State.Current.Hero.Q);
                State.Current.GameField.Activate(State.Current.Hero.Position);
                break;

            case ConsoleKey.W:
                AttackManager.Attack(State.Current.Hero.W);
                State.Current.GameField.Activate(State.Current.Hero.Position);
                break;

            case ConsoleKey.E:
                AttackManager.Attack(State.Current.Hero.E);
                State.Current.GameField.Activate(State.Current.Hero.Position);
                break;

            case ConsoleKey.R:
                AttackManager.Attack(State.Current.Hero.R);
                State.Current.GameField.Activate(State.Current.Hero.Position);
                break;

            case ConsoleKey.L:
                InfoMngr.LookAround();
                break;

            case ConsoleKey.Escape:
            {
                Select S = new Select();
                S.Title.Text = "What are you going to do next?";
                S.Options    = new List <Controls.Option>();
                S.Options.Add(new Controls.Option()
                    {
                        Color           = ConsoleColor.Gray,
                        Back            = ConsoleColor.Black,
                        Text            = "Resume",
                        CloseAfterClick = true,
                        Click           = () =>
                        {
                            Console.Clear();
                            State.Current.Info.Draw();
                            State.Current.Display.Draw();
                            State.Current.Chat.DrawTitleCustom();
                        }
                    });
                S.Options.Add(new Controls.Option()
                    {
                        Color           = ConsoleColor.Gray,
                        Back            = ConsoleColor.Black,
                        Text            = "Exit & Save",
                        CloseAfterClick = true,
                        Click           = () =>
                        {
                            InfoMngr.ExportLogColorless();
                            Environment.Exit(0);
                        }
                    });
                S.Options.Add(new Controls.Option()
                    {
                        Color           = ConsoleColor.Gray,
                        Back            = ConsoleColor.Black,
                        Text            = "Exi",
                        CloseAfterClick = true,
                        Click           = () =>
                        {
                            Environment.Exit(0);
                        }
                    });
                S.Run();
                break;
            }

            default: break;
            }
            Input.Invoke();
            State.Current.Info.Draw();
            Handle();
        }
    // Update is called once per frame
    void Update()
    {
        Vector2 move = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));

        if (move.magnitude * runSpeed > (move.normalized * runSpeed).magnitude)
        {
            move = move.normalized * runSpeed;
        }
        else
        {
            move = move * runSpeed;
        }
        //Debug.Log(move);
        //ANIM
        if (move.magnitude != 0)
        {
            //anim.SetTrigger(runHash);
            anim.SetBool(runBooleanHash, true);
            currentState = EntityState.RUNNING;

            //Debug.Log("Setting trigger");
            if (move.x < 0)
            {
                sRenderer.flipX = true;
            }
            else if (move.x > 0)
            {
                sRenderer.flipX = false;
            }
        }
        else
        {
            // anim.SetTrigger(idleHash);
            anim.SetBool(runBooleanHash, false);
            currentState = EntityState.STANDING;
        }
        if (Input.GetAxis("Attack1") != 0)
        {
            //anim.SetBool(runBooleanHash, false);
            anim.SetBool(attackOneHash, true);
            if (blockingMovement != true)
            {
                blockingTime = Time.time + ATTACKONETIME;

                source.PlayOneShot(attackSound, 0.7f);
                attackMan.Attack(sRenderer.flipX);
            }

            blockingMovement = true;
        }
        else
        {
            anim.SetBool(attackOneHash, false);
        }


        if (Input.GetAxis("Interact") != 0)
        {
            GameObject[] entities = GameObject.FindGameObjectsWithTag("Interactable");
            foreach (GameObject e in entities)
            {
                if (Vector3.Distance(e.transform.position, transform.position) < 1.5f)
                {
                    MonoBehaviour[] list = e.GetComponents <MonoBehaviour>();
                    foreach (MonoBehaviour mb in list)
                    {
                        if (mb is IInteractable)
                        {
                            IInteractable interactable = (IInteractable)mb;
                            interactable.OnInteract();
                            //Debug.Log("Interacting with something");
                        }
                    }
                }
            }
        }


        if (blockingMovement)
        {
            if (Time.time > blockingTime)
            {
                blockingMovement = false;
            }
            else
            {
                move = new Vector2(0, 0);
            }
        }



        //MOVEMENT
        transform.position = transform.position + new Vector3(move.x, move.y) * Time.deltaTime;

        DoSound();
    }
예제 #12
0
파일: Enemy.cs 프로젝트: WindowWasher/LD41
    // Update is called once per frame
    void Update()
    {
        //if (!agent.isOnNavMesh)
        //{
        //    NavMeshHit hit = new NavMeshHit();
        //    if(NavMesh.SamplePosition(this.transform.position, out hit, 10f, NavMesh.AllAreas))
        //    {
        //        this.transform.position = hit.position + new Vector3(0,1,0);
        //    }
        //    else
        //    {
        //        Die();
        //        return;
        //    }
        //}

        if (!setTargetTimer.Expired())
        {
            return;
        }

        if (target == null)
        {
            resetTarget();
        }

        //if(agent.destination == this.transform.position && agent.destination != targetPosition)
        //{
        //    agent.SetDestination(targetPosition);
        //}
        if (target != null && nextRangeCheck.Expired())
        {
            if (attacking || attackManager.InRange(target.transform.position))
            {
                attacking = true;
                if (!agent.isStopped)
                {
                    agent.isStopped = true;
                }
                if (attackManager.AttackReady())
                {
                    attackManager.Attack(target);
                    AudioSource.PlayClipAtPoint(audioClip, transform.position + new Vector3(0, 25, 0), 1.0f);
                }
            }
            else
            {
                nextRangeCheck.Start(1);
                if (agent.isStopped)
                {
                    agent.isStopped = false;
                }
                if (agent.velocity == Vector3.zero)
                {
                    if (stoppedLastTime)
                    {
                        setTarget(Target.GetClosestTarget(this.transform.position, "Building"));
                    }
                    else
                    {
                        stoppedLastTime = true;
                    }
                }
            }
        }
    }