Beispiel #1
0
 // Update is called once per frame
 void Update()
 {
     if (this.gameObject.CompareTag("Player1"))
     {
         if (Input.GetKeyDown(KeyCode.Keypad0) && !spawned)
         {
             GameObject bullet = Resources.Load("Bullet") as GameObject;
             leanObj.Spawn(p1fire.position, transform.rotation);
             //bullet.transform.position = new Vector3(0, 10, 0);
             leanObj.Despawn(bullet, 2f);
             spawned = true;
             FindObjectOfType <AudioManager>().Fire();
             triggerDelay = 1;
         }
     }
     else if (this.gameObject.CompareTag("Player2"))
     {
         Transform parent = GameObject.FindGameObjectWithTag("Player2").transform;
         if (Input.GetKeyDown(KeyCode.Space) && !spawned)
         {
             GameObject bullet = Resources.Load("Bullet") as GameObject;
             leanObj.Spawn(p1fire.position, transform.rotation);
             //bullet.transform.position = new Vector3(0,10,0);
             leanObj.Despawn(bullet, 2f);
             spawned = true;
             FindObjectOfType <AudioManager>().Fire();
             triggerDelay = 1;
         }
     }
     Reset();
 }
Beispiel #2
0
    //========================================================== Spawn
    public void SpawnAttack()
    {
        if (_canAttack == true)
        {
            // Basic Ability
            if (PlayerManager.Instance.isSpecial == false)
            {
                _direction = PlayerManager.Instance.AimPosition - _attackSpawner.position;
                Ability _ability = _poolBasic.Spawn(_attackSpawner.position, GetRotation(_direction)).GetComponent <Ability>();

                if (_ability.Pool == null)
                {
                    _ability.Pool = _poolBasic;
                }
            }


            // Special Ability
            else if (PlayerManager.Instance.isSpecial == true)
            {
                Ability _ability = null;

                switch (_spawnPlace)
                {
                case specialSpawnPlace.spawner:
                    _direction = PlayerManager.Instance.AimPosition - _attackSpawner.position;
                    _ability   = _poolSpecial.Spawn(_attackSpawner.position, GetRotation(_direction)).GetComponent <Ability>();
                    break;

                case specialSpawnPlace.player:
                    _direction = PlayerManager.Instance.AimPosition - PlayerManager.Instance.Player.position;
                    _ability   = _poolSpecial.Spawn(PlayerManager.Instance.Player.position, GetRotation(_direction)).GetComponent <Ability>();
                    break;

                case specialSpawnPlace.aimPosition:
                    _direction = Vector3.zero;
                    _ability   = _poolSpecial.Spawn(PlayerManager.Instance.AimPosition, GetRotation(_direction)).GetComponent <Ability>();
                    break;
                }

                if (_ability.Pool == null)
                {
                    _ability.Pool = _poolSpecial;
                }
            }

            StartCoroutine(CR_AttackCD());
            _direction = Vector3.zero;
        }
    }
Beispiel #3
0
    public void Init(GameManager manager)
    {
        _manager = manager;

        GameConfig config = manager.Config;

        int maxCards = Random.Range(config.MinPlayerCards, config.MaxPlayerCards);

        // Spawn initial cards.
        for (int i = 0; i < maxCards; i++)
        {
            CardController card = new CardController();

            GameObject go   = _pool.Spawn(config.CardInitialPosition, Quaternion.identity);
            CardView   view = go.GetComponent <CardView>();

            card.Init(this, view);
            view.Init(card, _pool);

            card.SetValue(config.CardBaseCost, CardValueType.Cost);
            card.SetValue(config.CardBaseAttack, CardValueType.Attack);
            card.SetValue(config.CardBaseDefense, CardValueType.Defense);

            view.SetImage(_manager.CardImages[i]);
            view.SetOrder(i);

            CalculateTargetPositionAndRotation(i, maxCards, out Vector3 position, out Vector3 rotation);

            view.SetTargetPositionAndRotation(position, rotation, 1.0f);

            card.StateChanged += OnCardStateChanged;

            Cards.Add(card);
        }
    }
Beispiel #4
0
 private void KnifeAttack()
 {
     for (int i = 0; i < _knifePoints.Length; i++)
     {
         _knifePool.Spawn(_knifePoints[i], Quaternion.Euler(-90, 0, 0));
     }
 }
Beispiel #5
0
        public ExplodeParticle GetNewExplodeParticle()
        {
            GameObject explodeParticleGO = explodeParticlePool.Spawn(Vector3.zero, Quaternion.Euler(Vector3.zero));

            if (explodeParticleGO)
            {
                return(explodeParticleGO.GetComponent <ExplodeParticle>());
            }
            return(null);
        }
Beispiel #6
0
 //响应动画事件
 public void ThrowKnife()
 {
     if (Mathf.Abs(transform.position.x + 1.3f) <= _AllowableError)
     {
         _throwPos[0].z = transform.position.z;
         _knifeTemp     = _knifePool.Spawn(_throwPos[0] + Vector3.forward * 0.5f + Vector3.up, Quaternion.Euler(90, 0, 0));
     }
     else if (Mathf.Abs(transform.position.x) <= _AllowableError)
     {
         _throwPos[1].z = transform.position.z;
         _knifeTemp     = _knifePool.Spawn(_throwPos[1] + Vector3.forward * 0.5f + Vector3.up, Quaternion.Euler(90, 0, 0));
     }
     else if (Mathf.Abs(transform.position.x - 1.3f) <= _AllowableError)
     {
         _throwPos[2].z = transform.position.z;
         _knifeTemp     = _knifePool.Spawn(_throwPos[2] + Vector3.forward * 0.5f + Vector3.up, Quaternion.Euler(90, 0, 0));
     }
     //更改刀的层
     else
     {
         _knifeTemp = _knifePool.Spawn(transform.position + Vector3.forward * 0.5f + Vector3.up, Quaternion.Euler(90, 0, 0));
     }
     _knifeTemp.layer = LayerMask.NameToLayer("Weapon");
 }
Beispiel #7
0
    private static void SpawnFOWTeamViewObjects(int[] teams, LeanGameObjectPool pool, ActiveMap map)
    {
        //aca debo entregar una lista con todas las entidades que generan vision de un team y cual es su rango.
        var visionPointOfTeam = SightSystem.GetVisionPointsForEachTeam(teams);

        foreach (var point in visionPointOfTeam)
        {
            //debo agragarle la altura
            var elevation = MapUtilities.GetElevationOfPosition(point.center);
            var fixPositionNoElevation = map.layout.HexToWorld(point.center);
            var fixScale = map.layout.size * point.radius;

            var position      = new Vector3((float)fixPositionNoElevation.x, (float)fixPositionNoElevation.y + elevation);
            var scale         = new Vector3((float)fixScale.x, (float)fixScale.y) * 2;
            var spawnedObject = pool.Spawn(position, Quaternion.identity);
            spawnedObject.transform.localScale = scale;
        }
    }
 /// <summary>
 /// Loads a Throwable into a DisplaySpot
 /// </summary>
 /// <param name="throwSpot">Where on world will the Throwable Spawn and be child of</param>
 /// <returns></returns>
 protected virtual Throwable LoadThrowableIntoSpot(Transform throwSpot)
 {
     return(ThrowablePool.Spawn(throwSpot.position, Quaternion.identity, throwSpot)
            .GetComponent <Throwable>());
 }
Beispiel #9
0
 public void ThrowKnife()
 {
     _knifePool.Spawn(transform.position + transform.forward + Vector3.up, Quaternion.Euler(-90, 0, 0));
 }
Beispiel #10
0
 public BombHexagon GetNewBombHexagon()
 {
     return(bombHexagonPool.Spawn(Vector3.zero, Quaternion.Euler(Vector3.zero)).GetComponent <BombHexagon>());
 }
Beispiel #11
0
 public void PlaySound(string name)
 {
     PlayClip(sounds.Single(x => x.name == name).clip, soundPool.Spawn(transform));
 }
Beispiel #12
0
 public GameObject SpawnPlayerControlledObject(Vector3 position, Transform parent = null, bool worldPositionStays = true)
 {
     _playerControlledObjectCount++;
     return(_pool.Spawn(position, Quaternion.identity, parent, worldPositionStays));
 }
Beispiel #13
0
    public void SpawnHitEnemy(Vector3 pos)
    {
        var ps = _poolAttackHitEnemy.Spawn(pos, Quaternion.identity).GetComponent <VFXLifetime>();

        ps.Pool = _poolAttackHitEnemy;
    }