Exemple #1
0
 // Use this for initialization
 void Start()
 {
     ghostFrustum   = transform.GetComponentInChildren <Frustum>();
     ghostBehaviour = GetComponent <GhostBehaviour>();
     startSpeed     = ghostBehaviour.movementSpeed;
     startAccel     = ghostBehaviour.acceleration;
 }
Exemple #2
0
 public void DeRegisterEnemyToRadarHelper(GhostBehaviour enemy)
 {
     for (int i = 0; i < RadarHelper.Count; ++i)
     {
         RadarHelper[i].DeregisterEnemy(enemy);
     }
 }
    public void DeregisterEnemy(GhostBehaviour enemyToDestroy)
    {
        var enemy = enemies.Find(x => x.targetTransform == enemyToDestroy.transform);

        enemies.Remove(enemy);
        enemies.TrimExcess();
    }
    public void RegisterEnemy(GhostBehaviour newEnemy)
    {
        PickupGameObject newPickupGameObject = new PickupGameObject();

        newPickupGameObject.targetTransform = newEnemy.transform;
        enemies.Add(newPickupGameObject);
    }
Exemple #5
0
    void switchCharacter(GameObject character)
    {
        GameObject effect = (GameObject)Instantiate(Resources.Load("prefabs/PowerupGain"), transform.position, Quaternion.identity);

        effect.transform.SetParent(transform);
        Destroy(effect, 1.98f);

        Ghost.SetActive(false);
        FlyingCar.SetActive(false);
        FastShip.SetActive(false);
        character.SetActive(true);
        currentCharacter = character;
        ghostBehaviour   = null;
        agilityBehaviour = null;
        if (character.gameObject.name.Contains("Ghost"))
        {
            ghostBehaviour = (GhostBehaviour)character.gameObject.GetComponent <GhostBehaviour>();
        }

        if (character.gameObject.name.Contains("FlyingCar"))
        {
            agilityBehaviour = (AgilityBehaviour)character.gameObject.GetComponent <AgilityBehaviour> ();
        }
        playerAgilityFactor = 1.0f;
    }
Exemple #6
0
 // Use this for initialization
 void Start()
 {
     maxPlayers     = FindObjectOfType <NetManager>().maxPlayers;
     ghostBehaviour = GetComponent <GhostBehaviour>();
     roomCollection = roomCollection = FindObjectOfType <RoomCollection>();
     animator       = GetComponentInChildren <Animator>();
     ResetFleeTimer();
     ResetCooldownTimer();
 }
 // Use this for initialization
 void Start()
 {
     ghostFrustum   = transform.GetComponentInChildren <Frustum>();
     startScale     = transform.localScale;
     endScale       = startScale * ghostScale;
     targetScale    = startScale;
     animator       = GetComponentInChildren <Animator>();
     ghostBehaviour = GetComponent <GhostBehaviour>();
 }
 public void PostStart()
 {
     ghostBehaviour = GetComponent <GhostBehaviour>();
     if (isServer)
     {
         //transform.parent.GetComponentInParent<EnemyBase>().ghostFrustum = this;
         Rpc_SetMeshes(peaceful);
         Rpc_ChangeFrustum((int)ghostState);
         //root = transform.gameObject;
     }
 }
    private void ResetThisGhostToNormalBehaviour(Ghost pGhost)
    {
        GhostBehaviour pPreviousBehaviour = (GhostBehaviour)(pGhost.m_pProceduralVariablesModule.GetVariable(c_sVariableName_pBehaviourGhostHadBeforeFleeing));

        if (pPreviousBehaviour == null)
        {
            return;
        }

        pGhost.GiveBehaviour(pPreviousBehaviour);
        pGhost.m_pProceduralVariablesModule.ResetVariable(c_sVariableName_pBehaviourGhostHadBeforeFleeing);
    }
Exemple #10
0
 public void SetBoundary(GhostBehaviour b, ref float[] x, int N)
 {
     for (int i = 1; i < N - 1; i++)
     {
         x[Pos(0, i, N)]     = b == GhostBehaviour.MirrorHorizontal ? -1 * x[Pos(1, i, N)] : x[Pos(1, i, N)];
         x[Pos(N - 1, i, N)] = b == GhostBehaviour.MirrorHorizontal ? -1 * x[Pos(N - 2, i, N)] : x[Pos(N - 2, i, N)];
         x[Pos(i, 0, N)]     = b == GhostBehaviour.MirrorVertical ? -1 * x[Pos(i, 1, N)] : x[Pos(i, 1, N)];
         x[Pos(i, N - 1, N)] = b == GhostBehaviour.MirrorVertical ? -1 * x[Pos(i, N - 2, N)] : x[Pos(i, N - 2, N)];
     }
     x[Pos(0, 0, N)]         = 0.5f * (x[Pos(1, 0, N)] + x[Pos(0, 1, N)]);
     x[Pos(0, N - 1, N)]     = 0.5f * (x[Pos(1, N - 1, N)] + x[Pos(0, N - 2, N)]);
     x[Pos(N - 1, 0, N)]     = 0.5f * (x[Pos(N - 2, 0, N)] + x[Pos(N - 1, 1, N)]);
     x[Pos(N - 1, N - 1, N)] = 0.5f * (x[Pos(N - 2, N - 1, N)] + x[Pos(N - 1, N - 2, N)]);
 }
Exemple #11
0
 /// <summary>
 /// Solve with Gauss-Seidel iterations for grid1 using grid2 as an intermediate step
 /// </summary>
 /// <param name="b">Behaviour at the boundary</param>
 /// <param name="a">Rate of aquisition from neighbours</param>
 /// <param name="c">Damping rate</param>
 public void LinSolve(GhostBehaviour b, int N, float a, float c, ref float[] x0, ref float[] x1)
 {
     for (int n = 0; n < iterations; n++)
     {
         for (int i = 1; i < N - 1; i++)
         {
             for (int j = 1; j < N - 1; j++)
             {
                 x1[Pos(i, j, N)] = (x0[Pos(i, j, N)] + a * (x1[Pos(i - 1, j, N)] +
                                                             x1[Pos(i + 1, j, N)] + x1[Pos(i, j - 1, N)] + x1[Pos(i, j + 1, N)])) / c;
             }
         }
         SetBoundary(b, ref x1, N);
     }
 }
Exemple #12
0
    IEnumerator EnableSpawnSphere(GhostBehaviour targetGhost)
    {
        //if (!spawnedCaptureSphere.activeInHierarchy)
        //spawnedCaptureSphere.SetActive (true);
        //spawnedCaptureSphere.transform.position = targetGhost.transform.position + Vector3.up;
        //Renderer rend = spawnedCaptureSphere.GetComponent<Renderer> ();
        float currentspherePercentage = 0.0f;

        while (currentspherePercentage < 1 - (targetGhost.CurrentHealth / targetGhost.maxHealth))
        {
            //spawnedCaptureSphere.transform.position = targetGhost.transform.position + Vector3.up;
            currentspherePercentage += sphereRechargeSpeed * Time.deltaTime;
            //rend.material.SetFloat ("_PercentageComplete", 1 - currentspherePercentage);
            yield return(null);
        }
    }
Exemple #13
0
    IEnumerator DisableSpawnSphere(GhostBehaviour targetGhost)
    {
        disablingCaptureSphere = true;
        //spawnedCaptureSphere.transform.position = targetGhost.transform.position + Vector3.up;
        float currentSpherePercentage = 1 - (targetGhost.CurrentHealth / targetGhost.maxHealth);

        //Renderer rend = spawnedCaptureSphere.GetComponent<Renderer> ();
        while (currentSpherePercentage > 0)
        {
            //spawnedCaptureSphere.transform.position = targetGhost.transform.position;
            currentSpherePercentage -= sphereRechargeSpeed * Time.deltaTime;
            //rend.material.SetFloat ("_PercentageComplete", 1 - currentSpherePercentage);
            yield return(null);
        }
        previousGhostBehaviour = null;
        disablingCaptureSphere = false;
    }
Exemple #14
0
    void AddDotRow(Vector3Int startPos)
    {
        var currPos = startPos;

        for (var i = 1; i < 20; i++)
        {
            currPos.x = i;
            DotsTilemap.SetTile(currPos, Dot);
            if (UnityEngine.Random.value < 0.05f)
            {
                var            ghostType = UnityEngine.Random.Range(0, 3);
                var            ghostPos  = LevelGrid.CellToWorld(currPos);
                GhostBehaviour behaviour = null;

                switch (ghostType)
                {
                case 0:
                    behaviour = new RedGhostBehaviour();
                    GhostManager.Instance.SpawnGhost(GhostManager.Instance.RedGhostPrefab, ghostPos, behaviour);
                    break;

                case 1:
                    behaviour = new OrangeGhostBehaviour();
                    GhostManager.Instance.SpawnGhost(GhostManager.Instance.OrangeGhostPrefab, ghostPos, behaviour);
                    break;

                case 2:
                    behaviour = new PinkGhostBehaviour();
                    GhostManager.Instance.SpawnGhost(GhostManager.Instance.PinkGhostPrefab, ghostPos, behaviour);
                    break;

                case 3:
                    behaviour = new RedGhostBehaviour();
                    GhostManager.Instance.SpawnGhost(GhostManager.Instance.RedGhostPrefab, ghostPos, behaviour);
                    GhostManager.Instance.SpawnGhost(GhostManager.Instance.BlueGhostPrefab, ghostPos, new BlueGhostBehaviour(behaviour.MovementHandler));
                    break;
                }

                behaviour?.SetMode(GhostMode.Chasing);
            }
        }
    }
Exemple #15
0
    void Advect(GhostBehaviour b, int N, ref float[] c0, ref float[] c1, ref float[] vx, ref float[] vy)
    {
        float x, y, s0, t0, s1, t1, dt0;

        dt0 = Time.deltaTime * N;
        for (int i = 1; i < N - 1; i++)
        {
            for (int j = 1; j < N - 1; j++)
            {
                x = i - dt0 * vx[Pos(i, j, N)];
                y = j - dt0 * vy[Pos(i, j, N)];
                if (x < 0.5f)
                {
                    x = 0.5f;
                }
                if (x > N + 0.5f)
                {
                    x = N + 0.5f;
                }
                int i0 = (int)x;
                int i1 = i0 + 1;
                if (y < 0.5f)
                {
                    y = 0.5f;
                }
                if (y > N + 0.5f)
                {
                    y = N + 0.5f;
                }
                int j0 = (int)y;
                int j1 = j0 + 1;
                s1 = x - i0;
                s0 = 1 - s1;
                t1 = y - j0;
                t0 = 1 - t1;
                c1[Pos(i, j, N)] = s0 * (t0 * c0[Pos(i0, j0, N)] + t1 * c0[Pos(i0, j1, N)]) + s1 * (t0 * c0[Pos(i1, j0, N)] + t1 * c0[Pos(i1, j1, N)]);
            }
        }
        SetBoundary(b, ref c1, N);
    }
    void LeaveCharacter(bool _disableAsWell)
    {
        //Later we will check which player activated this command. For now, let's set to player 1
        GameObject     ghostInControl = GhostManager.GetGhost(1);
        GhostBehaviour ghostScript    = ghostInControl.GetComponent <GhostBehaviour>(); //save a reference to his script

        ghostInControl.transform.position = transform.position;                         //set ghost to where possessed enemy was
        ghostScript.StopMoving();                                                       //stop character's velocity
        Camera.main.transform.parent = ghostInControl.transform;                        //set camera's parent back to ghost
        ghostInControl.layer         = frontLayer;                                      //send ghost to front layer if he isn't already
        if (ghostInControl.transform.localScale.x > 0 && transform.localScale.x < 0 ||
            ghostInControl.transform.localScale.x < 0 && transform.localScale.x > 0)    //if player is facing the other direction from ghost
        {
            ghostScript.FlipSprite();                                                   //flip ghost sprite
        }
        ghostInControl.renderer.enabled = true;                                         //set his renderer back on so he can be seen
        ghostScript.controlState        = ControlState.PlayerControlled;                //player can control the ghost again
        Destroy(gameObject);                                                            //ghost kills the character he possessed when he's done
        if (_disableAsWell)                                                             //if the disable as well boolean is set to true
        {
            ghostScript.controlState = ControlState.Disabled;                           //disable the ghost. this is ideal for when he reaches the goal
        }
    }
 void Awake()
 {
     //agent = GetComponent<NavMeshAgent>();
     //ghostPosition = GetComponentInChildren<GhostBodyAdjustments>();
     ghostBehaviour = GetComponent <GhostBehaviour> ();
 }
Exemple #18
0
 // Use this for initialization
 void Start()
 {
     ghostBehaviour = GetComponent <GhostBehaviour>();
 }
Exemple #19
0
    public void Diffuse(float diff, GhostBehaviour b, int N, ref float[] x0, ref float[] x1)
    {
        float a = Time.deltaTime * diff * grid1.N * grid1.N;

        LinSolve(b, N, a, 1 + 4 * a, ref x0, ref x1);
    }
Exemple #20
0
 public void GiveBehaviour(GhostBehaviour pBehaviour)
 {
     m_pBehaviour = pBehaviour;
     pBehaviour.InitBehaviour(this);
 }
Exemple #21
0
    //private int ghostCount = 0;

    //void OnTriggerEnter(Collider other)
    //{
    //    if (other.GetComponent<EnemyBase>())
    //        ghostCount++;
    //}

    //void OnTriggerExit(Collider other)
    //{
    //    if (other.GetComponent<EnemyBase>())
    //        ghostCount--;
    //}

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F3))
        {
            RevokePlayerControlAndSetPlayerAIToTarget(positionOnSpawn);
        }
        //     if (navMeshAgent.enabled)
        //     {
        //planeProjection = Vector3.ProjectOnPlane(navMeshAgent.velocity, m_GroundNormal);
        //planeProjection = transform.TransformDirection(planeProjection);
        //m_TurnAmount = planeProjection.x;
        //m_ForwardAmount = planeProjection.z;

        //         UpdateAnimator(transform.InverseTransformDirection(navMeshAgent.velocity));
        //         if (Vector3.Distance(transform.position, navMeshAgent.destination) < 2.5f &&  navMeshAgent.remainingDistance <= navMeshAgent.stoppingDistance)
        //         {
        //             navMeshAgent.enabled = false;
        //             DisableControls = false;
        //         }
        //     }
        //     else
        {
            if (firing)
            {
                if (!hasStarted)
                {
                    if (curresntStartupTime < startupTime)
                    {
                        if (isLocalPlayer)
                        {
                            shake.ShakeCamera((curresntStartupTime / startupTime) * cameraShakeIntensity, Time.deltaTime);
                        }
                        curresntStartupTime += Time.deltaTime;
                        for (i = 0; i < joysticks.Count; ++i)
                        {
                            if (!joysticks [i].supportsVibration)
                            {
                                continue;
                            }
                            joysticks[i].SetVibration((curresntStartupTime / startupTime), (curresntStartupTime / startupTime));
                        }
                    }
                    else
                    {
                        hasStarted = true;
                        virtaulWeaponAudioSource.clip = weaponMainSound;
                        virtaulWeaponAudioSource.loop = true;
                        virtaulWeaponAudioSource.Play();
                    }
                }
                else
                {
                    if (currentWeaponTime < maxWeaponTime)
                    {
                        if (!lineRenderer.enabled || !beamLight.gameObject.activeInHierarchy)
                        {
                            lineRenderer.enabled = true;
                            beamLight.gameObject.SetActive(true);
                        }
                        rootMuzzleParticleSystem.Play();
                        if (isLocalPlayer)
                        {
                            shake.ShakeCamera(1 * cameraShakeIntensity, Time.deltaTime);
                        }

                        for (i = 0; i < joysticks.Count; ++i)
                        {
                            if (!joysticks [i].supportsVibration)
                            {
                                continue;
                            }
                            joysticks[i].SetVibration(1, 1);
                        }

                        ray = new Ray(m_Camera.transform.position + m_Camera.transform.forward * m_Camera.nearClipPlane, weaponSpawnPoint.forward);

                        endPosition = weaponSpawnPoint.position + weaponSpawnPoint.forward * distance;
                        vertCount   = Mathf.RoundToInt(distance);
                        lineRenderer.SetVertexCount(vertCount);
                        if (vertCount > 0)
                        {
                            lineRenderer.SetPosition(0, weaponSpawnPoint.position);
                        }
                        effectDistance = distance;

                        if (Physics.Raycast(ray, out hit, distance))
                        {
                            endPosition    = hit.point;
                            effectDistance = Mathf.Abs(Vector3.Distance(hit.point, weaponSpawnPoint.position));
                            GhostBehaviour gb = hit.transform.GetComponentInParent <GhostBehaviour>();
                            if (gb)
                            {
                                if (isLocalPlayer)
                                {
                                    gb.TakeDamage(playerID, damagePerSecond * Time.deltaTime);
                                }
                                //if (!spawnedCaptureSphere.activeInHierarchy)
                                //spawnedCaptureSphere.SetActive (true);
                                previousGhostBehaviour = gb;
                                //spawnedCaptureSphere.transform.position = hit.transform.gameObject.transform.position + Vector3.up;
                                //spawnedCaptureSphere.GetComponent<Renderer> ()
                                //.material.SetFloat ("_PercentageComplete",
                                //1 -
                                //(gb.CurrentHealth /
                                //gb.maxHealth));
                            }
                            else
                            {
                                StartParticleSystem();
                                Vector3 norm = weaponSpawnPoint.position - hit.point;
                                norm.Normalize();
                                spawnedParticleSystem.position = hit.point + norm * 0.1f;
                                //if (spawnedCaptureSphere.activeInHierarchy && !disablingCaptureSphere && previousGhostBehaviour)
                                //	StartCoroutine (DisableSpawnSphere (previousGhostBehaviour));
                                //if(!spawningHitDecal)
                                //	StartCoroutine(SpawnHitDecal(hit.point, Quaternion.Euler(hit.normal)));
                                //spawnedCaptureSphere.SetActive(false);
                            }
                        }
                        else
                        {
                            StopParticleSystem();
                            //if(spawnedCaptureSphere.activeInHierarchy)
                            //spawnedCaptureSphere.SetActive(false);
                            //spawnedCaptureSphere.SetActive(false);
                            distance += distanceOverTime * Time.deltaTime;
                        }

                        streamShape.radius = effectDistance / 2;
                        streamPartcileSystem.transform.parent.position = weaponSpawnPoint.position + weaponSpawnPoint.forward * (effectDistance / 2);
                        streamPartcileSystem.transform.parent.LookAt(weaponSpawnPoint.position);

                        halfDist = effectDistance / 2;
                        beamLightCLight.m_TubeLength = halfDist;
                        //beamLight.transform.localPosition = Vector3.zero;
                        //beamLight.transform.localRotation = Quaternion.Euler (Vector3.up * 90);

                        previousPos = weaponSpawnPoint.position;
                        for (i = 1; i < vertCount; i++)
                        {
                            //Set the position here to the current location and project it in the forward direction of the object it is attached to
                            pos = weaponSpawnPoint.position + weaponSpawnPoint.forward * i * (effectDistance / vertCount) +
                                  new Vector3(Random.Range(-lineNoise, lineNoise), Random.Range(-lineNoise, lineNoise), 0);

                            lineRenderer.SetPosition(i, pos);
                            if (!beamLightSegments[i].gameObject.activeInHierarchy)
                            {
                                beamLightSegments [i].gameObject.SetActive(true);
                            }
                            beamLightSegments [i].transform.position      = pos;
                            beamLightSegments [i].transform.localRotation = Quaternion.Euler(beamLightSegments [i].TransformDirection((previousPos - pos).normalized));
                            //beamLightSegments [i].transform.Rotate(beamLightSegments [i].up * 90);
                            beamLightSegments [i].transform.position += (previousPos - pos).normalized * 0.5f;
                            beamLightCLightSegments [i].m_TubeLength  = Mathf.Abs(Vector3.Distance(previousPos, pos) / 2);
                            beamLightSegments [i].transform.LookAt(previousPos);
                            previousPos = pos;
                        }
                        if (vertCount > 1)
                        {
                            lineRenderer.SetPosition(vertCount - 1, endPosition);
                            beamLightSegments [vertCount - 1].transform.position      = beamLightSegments [vertCount - 2].position;
                            beamLightSegments [vertCount - 1].transform.localRotation = Quaternion.Euler(beamLightSegments [vertCount - 1].TransformDirection((beamLightSegments [vertCount - 2].position - endPosition).normalized));
                            beamLightSegments [vertCount - 1].transform.position     -= (beamLightSegments [vertCount - 2].position - endPosition).normalized * Mathf.Abs(Vector3.Distance(beamLightSegments [vertCount - 2].position, endPosition) / 2);
                            beamLightSegments [vertCount - 1].transform.LookAt(endPosition);
                        }
                        beamLight.transform.position = (weaponSpawnPoint.position + endPosition) * 0.5f;
                        beamLight.transform.LookAt(endPosition);
                        currentWeaponTime += Time.deltaTime;
                    }
                    else
                    {
                        if (isLocalPlayer)
                        {
                            Cmd_EndFire();
                        }
                    }
                }
            }
        }

        //if (previousGhostBehaviour) {
        //spawnedCaptureSphere.transform.position = previousGhostBehaviour.transform.position;
        //}

        if (!firing)
        {
            if (currentWeaponTime > 0)
            {
                currentWeaponTime -= weaponRechargeRate * Time.deltaTime;
            }
            else
            {
                currentWeaponTime = 0;
            }
        }

        currentOverheatValue = currentWeaponTime / maxWeaponTime;
        weaponRechargeRenderer.SetFloat("_Capacity", 1 - currentOverheatValue);

        //if (isLocalPlayer)
        //{
        //    if (ghostCount > minGhostCountFearLevel)
        //    {
        //        fearLevel += (ghostCount / minGhostCountFearLevel) * Time.deltaTime;
        //        frost.FrostAmount = fearLevel / maxFearLevel;
        //    }
        //    else
        //    {
        //        if (fearLevel > 0)
        //        {
        //            fearLevel -= fearRechargeLevel * Time.deltaTime;
        //            frost.FrostAmount = fearLevel / maxFearLevel;

        //        }
        //    }
        //}
    }