Esempio n. 1
0
 // Instantiates arrow and particle effects
 void spawnVFX(bool _hitScan)
 {
     if (!isLocalPlayer)
     {
         return;
     }
     if (firePoint != null)
     {
         GameObject MoveArrow;
         MoveArrow = Instantiate(effectToSpawn, firePoint.transform.position, Quaternion.identity);
         MoveArrow.GetComponent <MoveArrow>().nameTag = transform.name;
         MoveArrow.transform.localRotation            = firstPerson.GetCamRotation();
         MoveArrow.GetComponent <MoveArrow>().UpdateSpeed(increaseSpeed, _hitScan, gameObject);
         print(isClient + " client | server " + isServer);
         if (isClient && !isServer)
         {
             CmdOnShoot(increaseSpeed, _hitScan);
         }
         else
         {
             RpcDoShootEffect(increaseSpeed, _hitScan);
         }
     }
     else
     {
         Debug.Log("No fire point!");
     }
 }
Esempio n. 2
0
    private void onMoveButtonClick()
    {
        moveArrow = EntityManager.instantiateMoveArrow();
        moveArrow.init(board, currentPlayer, team.numMoves, team.numMoves, false, true);

        moveArrow.onClick  += moveTo;
        moveArrow.onCancel += cancelMove;
    }
Esempio n. 3
0
    private void onShootButtonClick()
    {
        moveArrow = EntityManager.instantiateMoveArrow();
        moveArrow.init(board, currentPlayer, currentPlayer.playerData.level, 1, true, false);

        moveArrow.onClick  += shootTo;
        moveArrow.onCancel += cancelShoot;
    }
Esempio n. 4
0
    private void OnLoad_ArrowComplete(string abname, GameObject obj)
    {
        obj.SetActive(false);

        if (ArrowObject != null)
        {
            GameObject.DestroyObject(ArrowObject.gameObject);
        }

        ArrowObject = obj.transform.GetComponent <MoveArrow>();
    }
Esempio n. 5
0
    void RpcDoShootEffect(float increaseSpeed, bool _hitScan)
    {
        if (isLocalPlayer)
        {
            return;
        }
        GameObject MoveArrow;

        MoveArrow = Instantiate(vfx[1], firePoint.transform.position, Quaternion.identity);
        MoveArrow.transform.localRotation = firstPerson.GetCamRotation();
        MoveArrow.GetComponent <MoveServerArrow>().UpdateSpeed(increaseSpeed, _hitScan, null);
        increaseSpeed = speed;
    }
Esempio n. 6
0
    public void DestroyObject()
    {
        if (ArrowObject != null)
        {
            GameObject.DestroyImmediate(ArrowObject.gameObject);
        }
        ArrowObject = null;

        if (null != MapObject)
        {
            GameObject.DestroyImmediate(MapObject.gameObject);
        }
        MapObject = null;
    }
Esempio n. 7
0
        private PuzzleTable Move(int round, MoveArrow moveArrow, PuzzleTable puzzle, PuzzleTable[] tablesStack)
        {
            var TempTable = new PuzzleTable(puzzle.PuzzleWeight, puzzle.PuzzleHeight);

            if (round > 0)
            {
                TempTable.SetPuzzle(tablesStack[round - 1]);
            }
            else
            {
                TempTable.SetPuzzle(puzzle);
            }

            TempTable.Move(moveArrow.StartIndex.Index_X, moveArrow.StartIndex.Index_Y, moveArrow.Move);
            return(TempTable);
        }
Esempio n. 8
0
    private IEnumerator FireBow()
    {
        coroutineStarted = true;
        anim.SetTrigger("ShootBow");           //get the animator doing that attack

        yield return(new WaitForSeconds(.3f)); //give it a bit of delay so we can see the player shoot first

        audio.PlayOneShot(shootSound, shootVolume);

        try                                                  //try to shoot it at a target by getting the closest nasty boi
        {
            timeBetweenAttacks = originalTimeBetweenAttacks; //reset time
            Collider2D[] enemiesToDamage = Physics2D.OverlapCircleAll(arrowAttackPosition.position, arrowAttackRange, allEnemies);
            enemiesToDamage[0].GetComponent <Enemy>().TakeDamage(arrowDamage);

            target = enemiesToDamage[0].gameObject;

            if (!target.GetComponent <Enemy>().deathCoroutineStarted)                       //if the enemy isn't already dying
            {
                Instantiate(hurtParticles, target.transform.position, Quaternion.identity); //put some blood particles on the enemy
            }
            audio.PlayOneShot(enemyHurtSound, enemyHurtVolume);

            playerScript.AddEnergy(chargePerAttack);

            arrowInstance = Instantiate(arrowPrefab, this.gameObject.transform.position, Quaternion.identity);//make the arrow appear
            moveArrow     = arrowInstance.GetComponent <MoveArrow>();
            //SET ARROW VALUES
            moveArrow.arrowSpeed          = arrowSpeed;                     //pass in variables to specific arrows
            moveArrow.isFacingRight       = movePlayerScript.isFacingRight; //pass in variables to specific arrows
            moveArrow.target              = target;
            moveArrow.targetArrowLifetime = targetArrowLifetime;
            moveArrow.damage              = arrowDamage;                                                       //so the arrow knows how much damage
        }
        catch (IndexOutOfRangeException)                                                                       //if there's nothing at that index, just shoot straight
        {
            arrowInstance = Instantiate(arrowPrefab, this.gameObject.transform.position, Quaternion.identity); //make the arrow appear
            moveArrow     = arrowInstance.GetComponent <MoveArrow>();
            //SET ARROW VALUES
            moveArrow.arrowSpeed             = arrowSpeed;                     //pass in variables to specific arrows
            moveArrow.isFacingRight          = movePlayerScript.isFacingRight; //pass in variables to specific arrows
            moveArrow.nonTargetArrowLifetime = nonTargetArrowLifetime;
        }
        coroutineStarted = false;
    }
Esempio n. 9
0
        private MoveArrow[] solve(PuzzleTable puzzle, int moveLimit)
        {
            puzzle.Fall();

            PuzzleTable[]    TablesStack     = new PuzzleTable[moveLimit];
            MoveArrow[]      Solution        = new MoveArrow[moveLimit];
            int[]            IndexOfLastmove = new int[moveLimit];
            List <MoveArrow> MoveList        = GetMoveList(puzzle);
            int MovelistCount = MoveList.Count;

            for (int i = 0; i < IndexOfLastmove.Length; i++)
            {
                IndexOfLastmove[i] = 0;
            }

            for (int i = 0; i < TablesStack.Length; i++)
            {
                TablesStack[i] = new PuzzleTable(puzzle.PuzzleWeight, puzzle.PuzzleHeight);
            }

            for (int MoveRound = 0; MoveRound < moveLimit; MoveRound++)
            {
                var MoveDirectionIndex = IndexOfLastmove[MoveRound];
                var MoveDirection      = MoveList[MoveDirectionIndex];
                TablesStack[MoveRound] = Move(MoveRound, MoveDirection, puzzle, TablesStack);
                IndexOfLastmove[MoveRound]++;
                if (IndexOfLastmove[MoveRound] >= MovelistCount - 1)
                {
                    //รอบ แรก
                    if (MoveRound <= 0)
                    {
                        return(null);
                    }
                    IndexOfLastmove[MoveRound] = 0;
                    TablesStack[MoveRound].SetPuzzle(TablesStack[MoveRound - 1]);
                    MoveRound = MoveRound - 2;
                }

                //รอบสุดท้าย
                if (MoveRound >= moveLimit - 1)
                {
                    if (TablesStack[MoveRound].IsSuccess)
                    {
                        for (int i = 0; i < Solution.Length; i++)
                        {
                            Solution[i] = MoveList[IndexOfLastmove[i] - 1];
                            if (i == 0)
                            {
                                Solution[i].FromMoveBoxType = puzzle.GetBoxsType(Solution[i].StartIndex.Index_X, Solution[i].StartIndex.Index_Y);
                                switch (Solution[i].Move)
                                {
                                case MoveMode.MoveRight:
                                    Solution[i].ToMoveBoxType = puzzle.GetBoxsType(Solution[i].StartIndex.Index_X + 1, Solution[i].StartIndex.Index_Y);
                                    break;

                                case MoveMode.MoveUp:
                                    Solution[i].ToMoveBoxType = puzzle.GetBoxsType(Solution[i].StartIndex.Index_X, Solution[i].StartIndex.Index_Y + 1);
                                    break;

                                default:
                                    break;
                                }
                            }
                            else
                            {
                                Solution[i].FromMoveBoxType = TablesStack[i - 1].GetBoxsType(Solution[i].StartIndex.Index_X, Solution[i].StartIndex.Index_Y);
                                switch (Solution[i].Move)
                                {
                                case MoveMode.MoveRight:
                                    Solution[i].ToMoveBoxType = TablesStack[i - 1].GetBoxsType(Solution[i].StartIndex.Index_X + 1, Solution[i].StartIndex.Index_Y);
                                    break;

                                case MoveMode.MoveUp:
                                    Solution[i].ToMoveBoxType = TablesStack[i - 1].GetBoxsType(Solution[i].StartIndex.Index_X, Solution[i].StartIndex.Index_Y + 1);
                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                        return(Solution);
                    }
                    else
                    {
                        if (MoveRound <= 0)
                        {
                            TablesStack[MoveRound].SetPuzzle(puzzle);
                        }
                        else
                        {
                            TablesStack[MoveRound].SetPuzzle(TablesStack[MoveRound - 1]);
                        }
                        MoveRound--;
                    }
                }
            }
            return(null);
        }