Ejemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        float elapsedTime = Time.fixedDeltaTime;

        for (int i = 0; i < attackEventList.Length; i++)
        {
            AttackEvent a = attackEventList[i];

            a.time -= elapsedTime;
            while (a.time < 0 && (a.repeat == 0 || a.round < a.repeat))
            {
                GameObject g = Instantiate(a.spawner, e.gameObject.transform.position, Quaternion.identity) as GameObject;
                g.transform.SetParent(e.transform);
                BulletSpawner s = g.GetComponent <BulletSpawner>();

                s.bulletCount = a.bullets;
                s.prefab      = a.bullet;
                s.behaviour   = a.behaviour;
                s.clr         = a.c;
                if (a.track)
                {
                    s.track = e.p.gameObject;
                }
                s.offset += a.offset;
                a.round++;
                a.time += a.cd;
            }
        }
    }
Ejemplo n.º 2
0
    private void OnEnable()
    {
        audioSource = GetComponent <AudioSource>();
        PickSong();

        bulletSpawner = FindObjectOfType <BulletSpawner>();
    }
Ejemplo n.º 3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Monster")
        {
            BulletSpawner bulletmonster = other.GetComponent <BulletSpawner>();

            if (bulletmonster != null)
            {
                bulletmonster.GetDamage(attackAmount);
            }
            Destroy(gameObject);
        }
        else if (other.tag == "Monster2")
        {
            MonsterCtrl alien = other.GetComponent <MonsterCtrl>();

            if (alien != null)
            {
                alien.GetDamage(attackAmount);
            }
            Destroy(gameObject);
        }
        else if (other.tag == "START")
        {
            FindObjectOfType <GameManager>().StartGame();
        }
        //Destroy(gameObject);
    }
Ejemplo n.º 4
0
    public static BulletSpawner Random()
    {
        BulletSpawner bs = new BulletSpawner();

        bs.angle = RandomDistributions.RandNormal(0, 45);
        bs.bulletSize = RandomDistributions.RandNormal(DEFAULT_BULLET_SIZE, 0.4f);

        bs.curveSpeed = RandomDistributions.RandNormal(DEFAULT_CURVE_SPEED, 10.0f);
        if (Mathf.Abs(bs.curveSpeed) < 15.0f) {
            bs.curveSpeed = 0;
        }

        if (UnityEngine.Random.value > 0.85) {
            bs.numSplits = Mathf.RoundToInt(RandomDistributions.RandNormal(2, 0.55f));
            bs.numSplitBullets = Mathf.RoundToInt(RandomDistributions.RandNormal(2, 0.55f));
            bs.splitDelay = RandomDistributions.RandNormal(DEFAULT_SPLIT_DELAY, 0.2f);

            if (bs.numSplits < 1 || bs.numSplitBullets < 2 || bs.splitDelay <= 0.0f) {
                bs.numSplitBullets = DEFAULT_SPLIT_BULLETS;
                bs.numSplits = DEFAULT_SPLITS;
                bs.splitDelay = DEFAULT_SPLIT_DELAY;
            }
        }

        return bs;
    }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        bulletSpw = gunPoint.GetComponent <BulletSpawner>();
        bool isShottingActive = bulletSpw.active;

        mousePos = Input.mousePosition;
    }
Ejemplo n.º 6
0
    void Start()
    {
        _spawner    = app.enemySpawner;
        _bulSpawner = app.bulletSpawner;

        StartCoroutine(FirstWaveCall(2));
    }
Ejemplo n.º 7
0
 // Start is called before the first frame update
 protected virtual void Awake()
 {
     rb                = GetComponent <Rigidbody2D>();
     bSpawner          = FindObjectOfType <BulletSpawner>();
     audio.audioSource = GetComponent <AudioSource>();
     coll              = GetComponent <CircleCollider2D>();
 }
Ejemplo n.º 8
0
 private void Start()
 {
     playerController = FindObjectOfType <PlayerController>();
     songController   = FindObjectOfType <SongController>();
     bulletSpawner    = FindObjectOfType <BulletSpawner>();
     gridGenerator    = FindObjectOfType <GridGenerator>();
 }
Ejemplo n.º 9
0
 private void Awake()
 {
     bulletShooter = GetComponent <BulletSpawner>();
     if (spawnPos == null)
     {
         Debug.LogError("No hay transformada de origen de disparo en la nave! Desactivando...", gameObject);
         bIsActive = false;
     }
 }
Ejemplo n.º 10
0
 public EnemyFactory(List <LifetimeEntity> enemyList, List <LifetimeEntity> bulletSpawnerList, BulletSpawner spawner, SpriteN sprite, Movement movement, int health = 100, float delay = 0)
 {
     bulletSpawner  = spawner;
     this.enemyList = enemyList;
     spawnerList    = bulletSpawnerList;
     this.sprite    = sprite;
     mMovement      = movement;
     this.health    = health;
 }
Ejemplo n.º 11
0
 // Start is called before the first frame update
 void Awake()
 {
     m_rigidbody2D = GetComponent <Rigidbody2D>();
     bulletspawner = GetComponent <BulletSpawner>();
     timer         = moveTimer;
     isMoving      = false;
     HP            = maxHP;
     healthbar.SetMaxHealth(maxHP);
 }
Ejemplo n.º 12
0
 // Start is called before the first frame update
 void Start()
 {
     bulletSpawner  = FindObjectOfType <BulletSpawner>();
     enemySpawner   = FindObjectOfType <EnemySpawner>();
     soundManager   = FindObjectOfType <SoundManager>();
     shop           = FindObjectOfType <ShopScript>();
     scoreText.text = "Score: " + score.ToString();
     soundManager.PlayTheme();
 }
Ejemplo n.º 13
0
    void Start()
    {
        Instance = this;
        m_minZ   = m_playerHead.position.z + m_minDistance;
        m_maxZ   = m_minZ + m_zRange;

        m_minX = m_playerHead.position.x - m_xRange / 2;
        m_maxX = m_minX + m_xRange;
    }
Ejemplo n.º 14
0
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
     bulletsPool = new Queue <Bullet>(countPool);
     fillQueue();
 }
Ejemplo n.º 15
0
 private void Awake()
 {
     robotAnimator       = GetComponent <Animator> ();
     robotAnimator.speed = robotSpeed;
     robotRigidBody      = GetComponent <Rigidbody> ();
     robotTransform      = GetComponent <Transform> ();
     spawner             = GetComponentInChildren <BulletSpawner>();
     SkillManager        = FindObjectOfType <SkillManager>();
 }
Ejemplo n.º 16
0
 override protected void Awake()
 {
     base.Awake();
     gameLogicManager = FindObjectOfType <GameLogicManager>();
     character        = GetComponent <TransformingRobotCharacter>();
     userController   = GetComponent <TransformingRobotUserController>();
     cameraController = GetComponentInChildren <CameraController>();
     bulletSpawner    = GetComponentInChildren <BulletSpawner>();
 }
Ejemplo n.º 17
0
 public void Initialize(WeaponConfig weaponConfig)
 {
     Config           = weaponConfig;
     _tip             = transform.GetComponentInChildren <GunTipTag>().transform;
     _bulletSpawner   = new BulletSpawner(weaponConfig.bulletConfig, transform);
     _fireRate        = weaponConfig.fireRate;
     _spreadAngleHalf = weaponConfig.spreadAngle / 2;
     _bulletsPerShot  = weaponConfig.bulletsPerShot;
     _initialScale    = transform.localScale;
 }
Ejemplo n.º 18
0
    public void Start()
    {
        curBulletsInClip    = bulletsPerClip;
        curBulletsNotInClip = numBulletsTotal - curBulletsInClip;

        bulletSpawner = GetComponentInChildren <BulletSpawner>();
        if (bulletSpawner == null)
        {
            Debug.LogError("There is no bullet component attached to this gun. Please attach a bullet component");
        }
    }
Ejemplo n.º 19
0
 private void Awake()  //Singleton method to destroy more than one BulletSpawner by checking if class instance already exists
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
     }
 }
Ejemplo n.º 20
0
        public void Spawn()
        {
            Enemy         e2 = new Enemy(sprite, mMovement.Clone(), health);
            BulletSpawner b  = this.bulletSpawner.Clone();

            enemyList.Add(e2);
            spawnerList.Add(b);
            e2.OnDeath += (sender, e1) =>
            {
                spawnerList.Remove(b);
            };
        }
Ejemplo n.º 21
0
    // Start is called before the first frame update
    void Start()
    {
        endPanel.SetActive(false);
        Time.timeScale = 0;
        bulletSpawner  = FindObjectOfType <BulletSpawner>();
        coinSpawner    = FindObjectOfType <CoinSpawner>();


        currentGold   = 0;
        currentTime   = 0;
        goldText.text = "Gold: " + currentGold;
    }
Ejemplo n.º 22
0
 void Start()
 {
     Player   = GameObject.Find("Player Parent");
     health   = MaxHealth;
     anim     = GetComponent <Animation>();
     body     = GetComponent <MeshRenderer>();
     initbody = body.material.GetColor("_BGColor");
     spawner  = GetComponentInChildren <BulletSpawner>();
     psystem  = GetComponentInChildren <ParticleSystem>();
     StartCoroutine(FireLazer());
     source = GetComponent <AudioSource>();
 }
Ejemplo n.º 23
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Monster"))
     {
         BulletSpawner bulletSpawner = other.GetComponent <BulletSpawner>();
         bulletSpawner?.GetDamage(attackAmount);
         Destroy(gameObject);
     }
     if (other.CompareTag("Monster2"))
     {
         MonsterCtrl ailen = other.GetComponent <MonsterCtrl>();
         ailen?.GetDamage(attackAmount);
         Destroy(gameObject);
     }
 }
Ejemplo n.º 24
0
        void Start()
        {
            var enemyData = GetComponentInParent <EnemyData>();

            audioSource = GetComponent <AudioSource>();
            controller  = GetComponentInParent <EnemyController>();
            shooter     = GetComponent <BulletSpawner>();
            enemyShot   = enemyData.GetShotSoundFX();
            canShoot    = Random.Range(0, 3) == 0 ? false : true;
            if (!canShoot)
            {
                timeToWaitBeforeShootingAgain = Random.Range(1f, 1.5f);
                StartCoroutine(CanShootAgain());
            }
            timeToWaitBeforeShootingAgain = enemyData.GetSecondsBetweenShots();
        }
Ejemplo n.º 25
0
    // Start is called before the first frame update
    void Start()
    {
        rbody         = GetComponent <Rigidbody2D>();
        anim          = GetComponent <Animator>();
        bulletSpawner = GetComponent <BulletSpawner>();
        inventoryMgr  = GetComponent <InventoryManager>();

        // TODO Have external task assign keymap?

        if (player == Player.PLAYER_1)
        {
            inputMap = new InputMap(1);
        }
        else if (player == Player.PLAYER_2)
        {
            inputMap = new InputMap(2);
        }
    }
Ejemplo n.º 26
0
    public void OnAttack()
    {
        //TODO: Add Animations for the the death
        //TODO: Add multiple health states with diffrent sprites for each
        Health--;
        if (Health <= 0)
        {
            BulletSpawner bulletSpawner = FindObjectOfType <BulletSpawner>();
            bulletSpawner.batteries.Remove(this);

            if (bulletSpawner.batteries.Count <= 0)
            {
                FindObjectOfType <SongController>().NextPhase();
            }

            Destroy(gameObject);
        }
    }
Ejemplo n.º 27
0
    /// <summary>
    /// float: seconds to be active for
    /// int: ?
    /// string: name of GameObject with BulletSpawner component to activate
    /// object: ?
    /// </summary>
    public void activateSpawner(AnimationEvent e)
    {
        GameObject spawner_ = gameObject.FindObject(e.stringParameter);

        if (!spawner_)
        {
            Debug.LogError("no gameObject called " + e.stringParameter + " found");
            return;
        }
        BulletSpawner spawner = spawner_.GetComponent <BulletSpawner>();

        if (!spawner)
        {
            Debug.LogError("" + spawner_ + " has no spawner script component");
            return;
        }

        spawner.activateForSeconds(e.floatParameter);
    }
Ejemplo n.º 28
0
 public void InitInGame()
 {
     ver    = StaticStrings.Vertical;
     hor    = StaticStrings.Horizontal;
     anim   = GetComponent <Animator>();
     player = GetComponentInChildren <B_Player>();
     player.initializeCanvas();
     //dependency with statemanager
     states.init();
     camerahandler = GetComponentInChildren <Camerahandler>();
     camerahandler.Init(this);
     playerActions = new PlayerActions(player, this, anim);
     player.Helper.INITIALIZETARGETEVENT(this);
     reciveTrget(playerActions.targets[0]);
     bs = GetComponentInChildren <BulletSpawner>();
     bs.INITIALIZING(player);
     player.reciveAnimator(anim);
     isInit = true;
     player.assignWeapons(weaponModel, SpecialWeaponModel);
     isfrozen = false;
 }
Ejemplo n.º 29
0
 // Start is called before the first frame update
 void Awake()
 {
     InteractPrompt.SetActive(false);
     alive         = true;
     audioSource   = GetComponent <AudioSource>();
     CurrentHealth = MaxHealth;
     upperBody     = transform.Find("UpperBody");
     bulletSpawner = upperBody.GetComponentInChildren <BulletSpawner>();
     lowerBody     = transform.Find("LowerBody");
     lb_animator   = lowerBody.GetComponentInChildren <Animator>();
     ub_animator   = upperBody.GetComponentInChildren <Animator>();
     lowerBodySR   = lb_animator.transform.GetComponent <SpriteRenderer>();
     upperBodySR   = ub_animator.transform.GetComponent <SpriteRenderer>();
     cc            = GetComponent <CharacterController>();
     lb_animator.SetInteger("walk", 0);
     ub_animator.SetBool("arms", false);
     ub_animator.SetBool("ActionInProgress", false);
     animationBaseSpeed = MoveSpeed / 80f;
     lb_animator.speed  = ub_animator.speed = animationBaseSpeed;
     ChangeUpperBodyMode(UpperBodyMode);
 }
    protected void BasicStart()
    {
        //Audio
        mShootAudio = GameObject.Find("ShootAudio").GetComponent <AudioSource>();

        mPlayer = GameObject.Find("Player").transform;
        if (mPlayer == null)
        {
            Debug.Log("no player found");
        }

        mOwner           = gameObject.GetComponent <EnemyManager>();
        mSpawner         = (BulletSpawner)FindObjectOfType(typeof(BulletSpawner));
        mSpawner.Emitter = gameObject;
        mOnEnemyStateChanged.Invoke();
        mLastTurn           = Time.time;
        mTimeStateActivated = Time.time;
        mLastTimeShooted    = Time.time;
        Assert.AreNotEqual(gameObject, null);
        mRigidBody = gameObject.GetComponent <Rigidbody2D>();
    }
Ejemplo n.º 31
0
    public void SpawnLevel()
    {
        levelNumber++;


        for (int i = 0; i < levelNumber; i++)
        {
            BulletSpawner spawner = spawners.ReQueue();
            spawner.transform.position  = Vector3.zero;
            spawner.transform.position += (Vector3)Random.insideUnitCircle.normalized * 8f;
            spawner.data  = spawnerDataList.GetRandom();
            spawner.inUse = true;
            if (levelNumber % 3 == 0)
            {
                spawner.SpawnHoming();
            }
            else
            {
                spawner.SpawnAngled();
            }
        }
    }
Ejemplo n.º 32
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            IsMouseVisible = true;

            var worldSpriteBatch = new SpriteBatchProxy(new SpriteBatch(GraphicsDevice));
            var hudSpriteBatch = new SpriteBatchProxy(new SpriteBatch(GraphicsDevice));
            _world = new World(Vector2.Zero);
            var physicsUpdater = new WorldUpdateableAdapter(_world);
            var controllersProcessor = new EntityProcessor<IController>();
            var controllersUpdater = new EntityUpdater<IController>(controllersProcessor);
            var modelsProcessor = new EntityProcessor<IModel>();
            var modelsUpdater = new EntityUpdater<IModel>(modelsProcessor);
            var viewsProcessor = new EntityProcessor<IView>();
            var viewsUpdater = new EntityUpdater<IView>(viewsProcessor);

            var worldMapViewProcessor = new EntityProcessor<IView>();
            var worldCharacterViewProcessor = new EntityProcessor<IView>();

            var worldViewCamera = new Camera(worldSpriteBatch) { ViewProcessors = new[] { worldMapViewProcessor, worldCharacterViewProcessor } };
            var hudViewCamera = new Camera(hudSpriteBatch);
            var updateStepMultiplexer = new UpdationMultiplexer { Updateables = { controllersUpdater, modelsUpdater, physicsUpdater, } };
            var drawMultiplexer = new DrawingMultiplexer { Drawables = { worldViewCamera, hudViewCamera } };
            _screen = new GameStateAdapter { UpdateStepUpdateable = updateStepMultiplexer, DrawStepUpdateable = viewsUpdater, Drawable = drawMultiplexer };

            var map = Content.Load<Map>("01");
            //добавить мапу как вьюху
            var mapView = new MapView(map);
            worldMapViewProcessor.Collect(mapView);

            //добавить стены в мир
            var wallBody = new Body(_world, Vector2.Zero);
            var verticesArrays = map.ObjectLayers["walls"].MapObjects
                .Select(mapObject => new Vertices(mapObject.Polyline.Points.Select(p => new Vector2(p.X/10f, p.Y/10f))));
            foreach (var vertices in verticesArrays)
                FixtureFactory.AttachChainShape(vertices, wallBody);

            //добавить танки как полноценные тройки MVC
            var bodyTexture = Content.Load<Texture2D>("body");
            var towerTexture = Content.Load<Texture2D>("tower");
            var bulletTexture = Content.Load<Texture2D>("bullet");

            IBulletModelFactory bulletModelFactory = new BulletModelFactory(_world);
            IBulletViewFactory bulletViewFactory = new BulletViewFactory(bulletTexture);
            IBulletSpawner bulletSpawner = new BulletSpawner(modelsProcessor, viewsProcessor, worldCharacterViewProcessor, bulletModelFactory, bulletViewFactory);

            ITankTowerFactory tankTowerFactory = new TankTowerFactory(bulletSpawner);
            ITankModelFactory tankModelFactory = new TankModelFactory(_world, tankTowerFactory);
            ITankViewFactory tankViewFactory = new TankViewFactory(bodyTexture, towerTexture);
            ITankControllerFactory tankUserControllerFactory = new TankUserControllerFactory();
            ITankControllerFactory tankEnemyControllerFactory = new TankEnemyControllerFactory();

            ITankSpawner userTankSpawner = new TankSpawner(modelsProcessor, controllersProcessor, viewsProcessor, worldCharacterViewProcessor, tankModelFactory, tankViewFactory, tankUserControllerFactory);
            ITankSpawner enemyTankSpawner = new TankSpawner(modelsProcessor, controllersProcessor, viewsProcessor, worldCharacterViewProcessor, tankModelFactory, tankViewFactory, tankEnemyControllerFactory);

            foreach (var mapObject in map.ObjectLayers["entities"].MapObjects)
            {
                var position = new Vector2(mapObject.Bounds.X/10f, mapObject.Bounds.Y/10f);
                var rotation = 0;
                switch (mapObject.Type)
                {
                    case "Player":
                        userTankSpawner.Spawn(position, rotation);
                        break;
                    case "Enemy":
                        enemyTankSpawner.Spawn(position, rotation);
                        break;
                }
            }

            foreach (var mapObject in map.ObjectLayers["triggers"].MapObjects)
            {
                if (mapObject.Type == "VictoryPoint")
                {
                    var body = new Body(_world, Vector2.Zero) { IsSensor = true };
                    FixtureFactory.AttachPolygon(new Vertices(mapObject.Polygon.Points.Select(p => new Vector2(p.X/10f, p.Y/10f))), 1, body);
                    body.OnCollision += (a, b, contact) => { Exit(); return false; };
                }
            }
        }