Exemplo n.º 1
0
        bool ContinuepHScan(ref PHScanMechanic scan, ref Player player)
        {
            //Scan Stop Conditions
            if (direction > 0)
            {
                if (currentScanPosition.x > startPosition.x + horizontalReach)
                {
                    finalAnimationStarted = true;
                    //scan = null;
                    //return false;
                }
            }
            else
            {
                if (currentScanPosition.x < startPosition.x - horizontalReach)
                {
                    finalAnimationStarted = true;
                    //scan = null;
                    //return false;
                }
            }

            if (!ignorepHLimit)
            {
                if (player.GetPlayerStatus().pHIndicator == null || player.GetPlayerStatus().pHUseCounter <= 0)
                {
                    Debug.Log("use counter: " + player.GetPlayerStatus().pHUseCounter + "  indicator: " + player.GetPlayerStatus().pHIndicator);
                    finalAnimationStarted = true;
                    //scan = null;
                    //return false;
                }
            }

            return(true);
        }
Exemplo n.º 2
0
 public void StartScan()
 {
     if (scan == null)
     {
         scan = new PHScanMechanic(player.GetGridCell(), player.transform.position, (int)player.playerSprite.transform.localScale.x,
                                   phScanVisualInfo);
     }
     else
     {
         Debug.Log("Scan is already in progress");
     }
 }
Exemplo n.º 3
0
        void FinalAnimation(ref PHScanMechanic scan)
        {
            //Target scale is now 0
            float   targetScale = 0;
            float   speed       = 5;
            Vector3 target      = new Vector3(1, targetScale, 1);

            if (scanVisualObject.transform.localScale.y - targetScale < 0.2f)
            {
                if (finalStepTimeElapsed == 0)
                {
                    ParticleSystem.MainModule module = ps.main;
                    module.simulationSpeed = finalFadeMultiplier;
                    ParticleSystem.EmissionModule em = ps.emission;
                    em.enabled       = false;
                    finalWaitPeriod /= module.simulationSpeed;
                }

                //Wait for a while for particles to disappear
                finalStepTimeElapsed += GameManager.Instance.DeltaTime;

                if (finalStepTimeElapsed > finalWaitPeriod)
                {
                    //Destroy the pH scanner visual object
                    Destroy(scanVisualObject);
                    scan = null;
                    return;
                }
            }

            scanVisualObject.transform.localScale = Vector3.Lerp(scanVisualObject.transform.localScale, target, speed * Time.deltaTime);

            //Animate the size of edge shape of the particle
            //ParticleSystem.ShapeModule shape = ps.shape;
            //shape.radius = scanVisualObject.transform.localScale.y;
        }
Exemplo n.º 4
0
        public void Update(ref PHScanMechanic scan, ref Player player)
        {
            if (finalAnimationStarted)
            {
                //If the final animation is playing, nothing else must be played.
                //If the control reaches this block, just return so that the rest of the code doesn't execute
                FinalAnimation(ref scan);
                return;
            }

            if (!ContinuepHScan(ref scan, ref player))
            {
                finalAnimationStarted = true;
            }

            if (!initialAnimationFinished)
            {
                InitialAnimation();
            }


            if (initialAnimationFinished)
            {
                currentScanPosition.x += speed * direction * GameManager.Instance.DeltaTime;
                //Position of the scan visual object must be set
                scanVisualObject.transform.position = currentScanPosition;

                //Debug.Log("current scan position: " + currentScanPosition);
                //Debug.DrawLine(Vector3.zero, currentScanPosition);
                Debug.DrawLine(new Vector3(currentScanPosition.x, currentScanPosition.y - verticalReach, currentScanPosition.z),
                               new Vector3(currentScanPosition.x, currentScanPosition.y + verticalReach, currentScanPosition.z),
                               Color.red);

                //Search all the nodes starting from the top range of the player's node


                GridCell previousCell = null;
                //Iterate the grid cells from bottom to top in the column searching for the items and enemies
                for (int i = -verticalReach; i < verticalReach; i++)
                {
                    GridCell         cellToCheck = null;
                    List <GridCell>  gridCells   = WorldGrid.Instance.gridArray[gridCell.index.x, gridCell.index.y + i];
                    List <Character> enemiesList = new List <Character>();

                    //if the grid cells exist, get the correct grid cell to check for enemies and items
                    Vector3 positionToCheck = new Vector3(currentScanPosition.x, currentScanPosition.y + i, currentScanPosition.z);
                    cellToCheck = WorldGrid.GetTheWorldGridCellWithoutCreatingNewCells(WorldGrid.GetGridIndex(positionToCheck));
                    if (cellToCheck == previousCell)
                    {
                        continue;
                    }
                    else
                    {
                        previousCell = cellToCheck;
                    }

                    if (cellToCheck == null)
                    {
                        Debug.LogError("Cell to check is null...Breaking out of the function");
                        continue;
                    }

                    Debug.Log("Cell to check position: " + cellToCheck.worldPosition);
                    enemiesList = cellToCheck.character;
                    Debug.Log("Drawing line");
                    Debug.DrawLine(Vector3.zero, cellToCheck.worldPosition, Color.red);


                    if (enemiesList != null)
                    {
                        for (int j = 0; j < enemiesList.Count; j++)
                        {
                            if (direction > 0)
                            {
                                if (enemiesList[j].transform.position.x <= currentScanPosition.x)
                                {
                                    Debug.Log("marked the enemy....Revealing pH");
                                    if (enemiesList[j].GetComponent <CharacterMechanics>())
                                    {
                                        RevealpH(enemiesList[j].GetComponent <CharacterMechanics>(), ref player);
                                    }
                                }
                            }
                            else
                            {
                                if (enemiesList[j].transform.position.x >= currentScanPosition.x)
                                {
                                    Debug.Log("marked the enemy....revealing pH");
                                    if (enemiesList[j].GetComponent <CharacterMechanics>())
                                    {
                                        RevealpH(enemiesList[j].GetComponent <CharacterMechanics>(), ref player);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }