Esempio n. 1
0
        public void SetupUnityScene()
        {
            templateProjectile      = GameObject.CreatePrimitive(PrimitiveType.Cube);
            templateProjectile.name = projectileName;

            spawner = new ProjectileSpawner(templateProjectile);
        }
        public override void Attack(Entity holder, Vector position, Vector direction)
        {
            float attackSpeed = AttackSpeed * (1 / AIAttackSpeedMod);

            if (Holder == "Player")
            {
                attackSpeed = AttackSpeed * PlayerStats.AttackSpeedMod;
            }

            Projectile projectile;

            if (ProjectileSpawner.CreateProjectile(position, attackSpeed, out projectile))
            {
                if (direction.X > 0)
                {
                    projectile.Physics.Velocity   = new Vector(ProjectileSpeed, 0);
                    projectile.Transform.Position = position + holder.GetComponent <Transform>().Scale - ProjectileScale +
                                                    new Vector(holder.GetComponent <Transform>().Scale.X / 1.5f, 0);
                }
                else
                {
                    projectile.Physics.Velocity   = new Vector(-ProjectileSpeed, 0);
                    projectile.Transform.Position = position + new Vector(0, holder.GetComponent <Transform>().Scale.Y) - ProjectileScale -
                                                    new Vector(holder.GetComponent <Transform>().Scale.X / 1.5f, 0) +
                                                    new Vector(ProjectileScale.X, 0);
                }
            }
        }
Esempio n. 3
0
        public override void Attack()
        {
            var random = new Random().Next(0, EnemyCells.Count);

            BattleUnitsView.TargetCell = EnemyCells.First(x => x == EnemyCells[random]);
            ProjectileSpawner.CreateAttackProjectile(base.Attack);
        }
    /// <summary>
    /// Awake is being used to initialize all the reference the class needs,
    /// and to bring it to an initial state.
    /// </summary>
    void Awake()
    {
        _timer  = 0f;
        _placed = false;
        _orginalProjectileMode   = true;
        _currentProjectile       = _projectiles[0];
        _currentProjectileDamage = _projectileDamages[0];
        _currentShootPace        = _projectilesShootPaces[0];
        _spawner      = GetComponentInChildren <ProjectileSpawner>();
        _targetFinder = GetComponentInChildren <TargetFinder>();
        _omc          = GetComponent <ObjectMaterialController>();
        _rotation     = GetComponentInChildren <Transform>();
        _transforms   = GetComponentsInChildren <Transform>();

        _damageMultiplier    = 1f;
        _shootPaceMultiplier = 1f;
        _collids             = false;

        level       = 1;
        sellValue   = costs / 2;
        upgradeCost = costs / 2;

        health = initialHealth;

        _omc.SetBaseMaterial(_placedMaterial);
        _spawner.SetProjectileSpeed(_projectileSpeed);
        _spawner.SetProjectileDamage(_currentProjectileDamage);
        _spawner.SetProjectile(_currentProjectile);
        SetLayerToPlaceMode();
    }
Esempio n. 5
0
    IEnumerator SpawnEnemies()
    {
        float timePassed = 0f;

        for (int i = 0; i < enemies.Count; i++)
        {
            Enemy enemy = enemies[i];
            yield return(new WaitForSeconds(enemy.timeToSpawn - timePassed));

            GameObject enemyObj = EnemyPool[i];

            enemyObj.transform.position = new Vector3(enemy.posX, enemy.posY, 0);
            Vector3 newPosition = new Vector3(enemy.endPosX, enemy.endPosY, 0);

            enemyObj.SetActive(true);

            ProjectileSpawner projectileSpawner = enemyObj.GetComponent <ProjectileSpawner>();
            projectileSpawner.enabled = false;

            float timeSinceStarted = 0f;

            while (enemyObj.transform.position != newPosition)
            {
                timeSinceStarted           += Time.deltaTime;
                enemyObj.transform.position = Vector3.Lerp(enemyObj.transform.position, newPosition, timeSinceStarted);
                yield return(null);
            }

            // projectileSpawner.enabled = true;
        }
    }
    // Use this for initialization
    void Start()
    {
        rb = GetComponent <Rigidbody>();

        projectileSpawner = GetComponent <ProjectileSpawner>();
        PlayerHealth      = HEALTH_MAX;
    }
Esempio n. 7
0
 public MeleeAttackState(FinitStateMachine stateMachine, Transform target, Transform castPoint, Transform spawnPoint) : base(stateMachine)
 {
     _target            = target;
     _castPoint         = castPoint;
     _spawnPoint        = spawnPoint;
     _projectileSpawner = new ProjectileSpawner("PushableProjectile", 0f);
 }
Esempio n. 8
0
        public void OnSpawn()
        {
            Enemies = SceneManager.GetCurrentScene().GetEntities <Enemy>();
            Player player = SceneManager.GetCurrentScene().GetEntity <Player>("Player");

            ProjectileSpawner = new ProjectileSpawner(ProjectileSprite, this);
        }
Esempio n. 9
0
    // Initializes the projectile. ProjectileSpawner has to be set only once (but can be set again).
    // If projSpawner is left to null, older spawner will be used. If there's no older spawner, returns false.
    // Angle is in degrees.
    // Returns true if the projectile was initialized correctly OR if it was already initialized.
    // Returns false if the projectile couldn't be initialized properly.
    public bool init(float speed, float angle, ProjectileSpawner projSpawner = null)
    {
        if (projSpawner != null && !initStatus)
        {
            spawner = projSpawner;
        }
        if (spawner == null)
        {
            Debug.LogError("Error: Projectile doesn't have its ProjectileSpawner set and it can't be initialized.");
            if (initStatus)
            {
                Debug.LogWarning("Warning: Projectile has already been initialized, won't be initialized again.");
            }
            return(false);
        }
        if (initStatus)
        {
            Debug.LogWarning("Warning: Projectile has already been initialized, won't be initialized again.");
            return(true);
        }


        if (!initMovement(speed, angle))
        {
            return(false);
        }

        cachedTransform      = transform;
        spawnPosition        = cachedTransform.position;
        initStatus           = true;
        internalDespawnTimer = despawnTimer;
        return(true);
    }
Esempio n. 10
0
    // Use this for initialization
    // Starts after everything has woken - must wait for gamecontrol
    void Start()
    {
        Screen.orientation  = ScreenOrientation.LandscapeLeft;
        this.entityMovement = GetComponent <EntityMovement>();
        Camera.main.GetComponent <CameraShake>().enabled = false;
        projectileSpawner         = GetComponent <PlayerProjectileSpawner>();
        meleeCollider.enabled     = false;
        attacking                 = false;
        lastAttack                = Time.time;
        temporaryInvulnerableTime = Time.time;
        rend = this.GetComponentInChildren <SkinnedMeshRenderer>();

        //Setup player sounds
        meleeAttackSound   = Resources.Load("Audio/melee_attack") as AudioClip;
        specialAttackSound = Resources.Load("Audio/special_attack") as AudioClip;
        rangedAttackSound  = Resources.Load("Audio/range_attack") as AudioClip;
        damageTakenSound   = Resources.Load("Audio/player_ugh") as AudioClip;
        jumpSound          = Resources.Load("Audio/player_jump") as AudioClip;

        //Get a component reference to the Player's animator component
        animator = GetComponent <Animator>();

        //Get stats from the GameControl
        strength      = GameControl.control.playerStr;
        agility       = GameControl.control.playerAgl;
        dexterity     = GameControl.control.playerDex;
        intelligence  = GameControl.control.playerInt;
        vitality      = GameControl.control.playerVit;
        abilityPoints = GameControl.control.abilityPoints;
        maxHealth     = vitality;
        currentHealth = maxHealth;
    }
Esempio n. 11
0
    public override void Init()
    {
        DataAttackShoot d = (DataAttackShoot)data;

        amount     = d.projectileAmount.value;
        delay      = d.spawnDelay.value;
        facePlayer = d.facePlayer.value;

        var speedMove     = d.speedMove.value;
        var speedRotation = d.speedRotation.value;
        var scale         = d.scale.value;
        var direction     = (ProjectileDirection)Enum.Parse(typeof(ProjectileDirection), d.projectileDirection.value);

        switch (direction)
        {
        case ProjectileDirection.STRAIGHT_FORWARD: spawner = new ProjectileSpawnerForward(boss, scale, speedMove, speedRotation);
            break;

        case ProjectileDirection.CIRCLE: spawner = new ProjectileSpawnerCircle(boss, scale, amount, speedMove, speedRotation);
            break;

        case ProjectileDirection.CIRCLE_HALF_UP: spawner = new ProjectileSpawnerCircleHalfUp(boss, scale, amount, speedMove, speedRotation);
            break;

        case ProjectileDirection.CIRCLE_HALF_DOWN: spawner = new ProjectileSpawnerCircleHalfDown(boss, scale, amount, speedMove, speedRotation);
            break;

        case ProjectileDirection.CIRCLE_HALF_FORWARD: spawner = new ProjectileSpawnerCircleHalfForward(boss, scale, amount, speedMove, speedRotation);
            break;

        default: spawner = new ProjectileSpawnerForward(boss, scale, speedMove, speedRotation);
            break;
        }
    }
Esempio n. 12
0
 public RangeAttackState(FinitStateMachine stateMachine, SkeletonData data) : base(stateMachine)
 {
     _animator          = data.Animator;
     _target            = data.Player;
     _spawnPoint        = data.ArrowSpawnPoint;
     _projectileSpawner = new ProjectileSpawner(data.ArrowPrefab.name, 0f);
 }
Esempio n. 13
0
        public SingleProjectileCaseState(FinitStateMachine stateMachine, Transform target, Transform spawnPoint)
            : base(stateMachine)
        {
            _target     = target;
            _spawnPoint = spawnPoint;

            _projectileSpawner = new ProjectileSpawner("MavkaSingleProjectile", 0f);
        }
Esempio n. 14
0
    public void SpawnProjectile(ProjectileSpawner spawner)
    {
        GameObject prefab = Instantiate(spawner.projectilePrefab, spawner.location.position, Quaternion.identity, projectilePartent) as GameObject;

        Projectile projectileScript = prefab.GetComponent <Projectile>();

        projectileScript.Push(spawner.velocity);
    }
Esempio n. 15
0
 private void Start()
 {
     GameManager       = FindObjectOfType <GameManager>();
     ProjectileSpawner = GetComponent <ProjectileSpawner>();
     ProjectileSpawner.ProjectileCountChangedEvent += ProjectileCountChanged;
     Rotator = GetComponent <Rotator>();
     SetScoreUI();
 }
        public override void Attack(Entity holder, Vector position, Vector direction)
        {
            Projectile projectile;

            if (ProjectileSpawner.AnimationBasedProjectile(holder, Holder, out projectile))
            {
            }
        }
Esempio n. 17
0
    }                                                                      //Singleton del bullet spawner

    void Awake()
    {
        _instance        = this;                                                                                                                             //Asigna el singleton
        _projectilePool  = new Pool <Projectile>(numberProjectiles, ProjectileFactory, Projectile.InitializeProjectile, Projectile.DisposeProjectile, true); //Crea el pool de objetos
        projectilePrefab = Instantiate(Resources.Load("Prefabs/Projectile", typeof(Projectile))) as Projectile;

        EventsManager.SubscribeToEvent(EventType.GP_ShootProjectile, GetProjectileFromPool);
    }
Esempio n. 18
0
        public ProjectileSpell(string projectileName, float cooldown, float minLenght, float maxLenght, float manaCoeff = 1f, float spawnDelay = 0f) : base()
        {
            _coolDownTime      = cooldown;
            _projectileSpawner = new ProjectileSpawner(projectileName, _spawnOffset, spawnDelay);

            _minLenght = minLenght;
            _maxLenght = maxLenght;
            _manaCoeff = manaCoeff;
        }
Esempio n. 19
0
 private void AssignInputListener(ProjectileSpawner add, ProjectileSpawner remove)
 {
     //remove "remove" from input evnet listner
     playerInput.holdShootEvent.RemoveListener(remove.StartAuto);
     playerInput.releaseShootEvent.RemoveListener(remove.StopAuto);
     //add "add" from input event listner
     playerInput.holdShootEvent.AddListener(add.StartAuto);
     playerInput.releaseShootEvent.AddListener(add.StopAuto);
 }
Esempio n. 20
0
    private void Start()
    {
        if (instance)
        {
            Destroy(instance.gameObject);
        }

        instance = this;
        prefab.SetActive(false);
    }
Esempio n. 21
0
 private void Awake()
 {
     input = GetComponent <InputReceiver>();
     if (projectileSpawner == null)
     {
         projectileSpawner = GetComponent <ProjectileSpawner>();
     }
     pingSpawner  = GetComponent <PingSpawner>();
     playerSprite = GetComponent <SpriteRenderer>();
 }
Esempio n. 22
0
    protected override void Awake()
    {
        base.Awake();
        _movement.Initialize(this);

        _lastGroundedPosition = transform.position;
        _groundDetector       = GetComponent <SolidGroundDetector>();
        _interactionFinder    = GetComponent <InteractionFinder>();
        _projectileSpawner    = GetComponentInChildren <ProjectileSpawner>();
    }
Esempio n. 23
0
        public override void Heal()
        {
            var cells = AllyCells
                        .Where(x => x.Unit.CurrentHealth < x.Unit.Data.Health)
                        .ToList();
            var random = new Random().Next(0, cells.Count);

            BattleUnitsView.TargetCell = cells[random];
            ProjectileSpawner.CreateHealProjectile(base.Heal);
        }
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
Esempio n. 25
0
    public void InstantiateSpawner(SpawnerData spawnerData, GameObject spawnerPrefab)
    {
        GameObject spawner = Instantiate(spawnerPrefab, spawnerData.position, Quaternion.Euler(0, 0, spawnerData.rotation));

        spawner.transform.parent = transform;
        ProjectileSpawner spawnerScript = spawner.GetComponent <ProjectileSpawner>();

        spawner.name = "Spawner " + (currentLevelSpawnerList.Count + 1) + " layer " + spawnerScript.layerData.layerIndex;
        spawnerScript.spawnerData = spawnerData;
        currentLevelSpawnerList.Add(spawnerScript);
    }
Esempio n. 26
0
 // Use this for initialization
 void Start()
 {
     characterStats = new CharacterStats();
     ai             = new Stack <AIBase>();
     init();
     initStats(startingHealth, startingSpeed, startingPower, startingDefense, startingVisionRange);
     if (startingAI != null)
     {
         addAIState(startingAI);
     }
     weapon = GetComponent <ProjectileSpawner>();
 }
Esempio n. 27
0
 // TODO: Use an observer pattern instead of a singleton
 private void Awake()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         Instance = this;
     }
     spawner = new ProjectileSpawner(projectile);
 }
Esempio n. 28
0
            public void SpawnProjectile(ProjectileType type, Vector3 position, Vector3 target)
            {
                for (int i = 0; i < this.Spawners.Length; i++)
                {
                    ProjectileSpawner spawner = this.Spawners[i];
                    if (spawner.Type == type)
                    {
                        spawner.Spawn(position, target);
                        return;
                    }
                }

                Debug.LogError("SpawnProjectile no spawner for " + type.ToString());
            }
Esempio n. 29
0
    void Start()
    {
        level    = FindObjectOfType <LevelManager>();
        spawner  = GetComponent <ProjectileSpawner>();
        animator = GetComponent <Animator>();

        if (tag == "Monster")
        {
            level.MonstersCount();
        }

        score         = FindObjectOfType <Score>();
        enemyCollider = GetComponent <Collider2D>();
    }
        public override void OnPointerClick(PointerEventData eventData)
        {
            var target = GetComponent <UnitCellView>();

            if (!IsHealTarget(target.Unit) || !IsPlayerCanTurn)
            {
                return;
            }

            IsPlayerCanTurn            = false;
            BattleUnitsView.TargetCell = target;
            ProjectileSpawner.CreateHealProjectile(ActiveCell.Behaviour.Heal);

            base.OnPointerClick(eventData);
        }
Esempio n. 31
0
    // Use this for initialization
    // Starts after everything has woken - must wait for gamecontrol
    void Start()
    {
        Screen.orientation = ScreenOrientation.LandscapeLeft;
        this.entityMovement = GetComponent<EntityMovement>();
        Camera.main.GetComponent<CameraShake>().enabled = false;
        projectileSpawner = GetComponent<PlayerProjectileSpawner>();
        meleeCollider.enabled = false;
        attacking = false;
        lastAttack = Time.time;
        temporaryInvulnerableTime = Time.time;
        rend = this.GetComponentInChildren<SkinnedMeshRenderer>();

        //Setup player sounds
        meleeAttackSound = Resources.Load("Audio/melee_attack") as AudioClip;
        specialAttackSound = Resources.Load("Audio/special_attack") as AudioClip;
        rangedAttackSound = Resources.Load("Audio/range_attack") as AudioClip;
        damageTakenSound= Resources.Load("Audio/player_ugh") as AudioClip;
        jumpSound = Resources.Load("Audio/player_jump") as AudioClip;

        //Get a component reference to the Player's animator component
        animator = GetComponent<Animator>();

        //Get stats from the GameControl
        strength = GameControl.control.playerStr;
        agility = GameControl.control.playerAgl;
        dexterity = GameControl.control.playerDex;
        intelligence = GameControl.control.playerInt;
        vitality = GameControl.control.playerVit;
        abilityPoints = GameControl.control.abilityPoints;
        maxHealth = vitality;
        currentHealth = maxHealth;
    }