Ejemplo n.º 1
0
    //Determine whether to use teleport trap to player
    private void UltimateSpellToPlayer()
    {
        //Has only 2 teleport traps
        if (ultimate_spell <= 0)
        {
            return;
        }
        //If there are less than 4 items, and Player is closer to most of it, then teleport player
        GameObject[] items = GameObject.FindGameObjectsWithTag("Item");
        if (items.Length <= 4)
        {
            int temp = 0;
            for (int i = 0; i < items.Length; i++)
            {
                if (Vector3.Distance(player.transform.position, items[i].GetComponent <Item>().transform.position) <
                    Vector3.Distance(transform.position, items[i].GetComponent <Item>().transform.position))
                {
                    temp++;
                }
            }
            if (temp >= items.Length / 2 + 1)
            {
                //teleport Player to a random alcove
                int player_location = new System.Random(System.Guid.NewGuid().GetHashCode()).Next(0, 10);
                player.GetComponent <BoxCollider>().enabled = false;
                player.transform.position = new Vector3(alcoves[player_location].x, alcoves[player_location].y, alcoves[player_location].z > 0 ? 8f : -8f);
                player.GetComponent <BoxCollider>().enabled = true;
                ultimate_spell--;

                Debug.Log("1");
            }
        }
    }
Ejemplo n.º 2
0
    public void SetPlayerType()
    {
        if (!playerAgent)
        {
            playerData.Type = PlayerType.Human;
            return;
        }

        BehaviorParameters behavior = playerAgent.GetComponent <BehaviorParameters>();

        switch (behavior.BehaviorType)
        {
        case BehaviorType.HeuristicOnly:
            playerData.Type = PlayerType.Human;
            break;

        case BehaviorType.InferenceOnly:
            playerData.Type = PlayerType.AI;
            break;

        case BehaviorType.Default:
            if (behavior.Model != null)
            {
                playerData.Type = PlayerType.AI;
            }
            else
            {
                playerData.Type = PlayerType.AI;
            }
            break;
        }
    }
Ejemplo n.º 3
0
    private void ResetPlayer()
    {
        Rigidbody rigidbody = playerAgent.GetComponent <Rigidbody>();

        rigidbody.velocity             = Vector3.zero;
        rigidbody.angularVelocity      = Vector3.zero;
        playerAgent.transform.position = ChooseRandomPosition(transform.position, 0f, 360f, 0f, 9f) + Vector3.up * .5f;
        playerAgent.transform.rotation = Quaternion.Euler(0f, UnityEngine.Random.Range(0f, 360f), 0f);
    }
Ejemplo n.º 4
0
        public void Trigger()
        {
            lightCollection = LG_LightCollection.Create(EnemyAgent.CourseNode, EnemyAgent.EyePosition, LG_LightCollectionSorting.Distance, EMPConfig.Radius);

            ExtraEnemyAbilities.log.LogDebug($"Collected {lightCollection.collectedLights.Count} lights");


            foreach (var collectedLight in lightCollection.collectedLights)
            {
                if (collectedLight.distance > EMPConfig.Radius)
                {
                    break;
                }
                LightEMPManager prevLightEMPMan = collectedLight.light.gameObject.GetComponent <LightEMPManager>();
                if (prevLightEMPMan != null)
                {
                    prevLightEMPMan.ResetDuration(EMPConfig);
                }
                else
                {
                    LightEMPManager lightEMPMan = collectedLight.light.gameObject.AddComponent <LightEMPManager>();
                    lightEMPMan.ResetDuration(EMPConfig);
                    lightEMPMan.CollectedLight = collectedLight;
                }
            }

            var targets = Physics.OverlapSphere(EnemyAgent.EyePosition, EMPConfig.Radius, LayerManager.MASK_EXPLOSION_TARGETS);

            int playerCount = 0;

            foreach (var target in targets)
            {
                PlayerAgent playerAgent = target.GetComponent <PlayerAgent>();
                if (playerAgent != null)
                {
                    if (playerAgent.IsLocallyOwned)
                    {
                        var existingPEMPM = playerAgent.GetComponent <PlayerEMPManager>();
                        if (existingPEMPM != null)
                        {
                            //TODO Duration
                            existingPEMPM.ResetDuration(EMPConfig.Duration);
                        }
                        else
                        {
                            PlayerEMPManager playerEMPManager = playerAgent.gameObject.AddComponent <PlayerEMPManager>();
                            if (playerEMPManager != null)
                            {
                                playerEMPManager.ResetDuration(EMPConfig.Duration);
                                playerEMPManager.triggered = true;
                            }
                            playerCount++;
                        }
                    }
                }
            }

            ExtraEnemyAbilities.log.LogDebug($"Added PlayerEMPManager to {playerCount} players.");



            Triggered = true;
        }