void OnTriggerStay2D(Collider2D other)
    {
        MoveableGridObject otherGridObject = other.GetComponent <MoveableGridObject>();
        BombObject         bombObject      = other.GetComponent <BombObject>();

        if (bombObject)
        {
            bombObject.Roll(direction);
        }
        if (other.gameObject.CompareTag("Player"))
        {
            PlayerGridObject player = other.GetComponent <PlayerGridObject>();
            if (player.platforms == 0)
            {
                player.Move(direction);
            }
        }
        else if (otherGridObject && !other.gameObject.CompareTag("WindSlime"))
        {
            otherGridObject.Move(direction);
            EnemyGridObject enemyGridObject = other.gameObject.GetComponent <EnemyGridObject>();
            if (enemyGridObject)
            {
                enemyGridObject.TakeDamage(damage);
            }
        }
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 protected override void Update()
 {
     if (!Globals.canvas.dialogue)
     {
         base.Update();
         if (noBomb)
         {
             frames++;
             if (frames >= regrowFrames)
             {
                 noBomb = false;
                 frames = 0;
                 GameObject newBomb = (GameObject)Instantiate(bombObject, this.gameObject.transform.position, Quaternion.identity);
                 bomb = newBomb.GetComponent <BombObject>();
                 bomb.setBombPlantObject(this);
             }
         }
     }
     if (isDying)
     {
         dyingFrame++;
         if (dyingFrame >= numDyingFrames)
         {
             Destroy(this.gameObject);
         }
     }
 }
Ejemplo n.º 3
0
        private void CheckImmediateDetonation()
        {
            collisionChecker = BombObject.GetComponentInChildren <ObstaclesStayDetectorForced>();
            collisionChecker.ReCheckCollisionsStart();

            GameManagerScript Game = GameObject.Find("GameManager").GetComponent <GameManagerScript>();

            Game.Movement.FuncsToUpdate.Add(UpdateColisionDetection);
        }
Ejemplo n.º 4
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        noBomb = false;
        frames = 0;
        GameObject newBomb = (GameObject)Instantiate(bombObject, this.gameObject.transform.position, Quaternion.identity);

        bomb = newBomb.GetComponent <BombObject>();
        bomb.setBombPlantObject(this);
    }
Ejemplo n.º 5
0
    protected void OnTriggerEnter2D(Collider2D other)
    {
        EnemyGridObject enemy = other.gameObject.GetComponent <EnemyGridObject>();

        if (enemy)
        {
            spinning.Add(other.gameObject);
        }
        BombObject bomb = other.gameObject.GetComponent <BombObject>();

        if (bomb)
        {
            bomb.LightFuse();
            bomb.GetComponent <Animator>().SetTrigger("Roll");
            spinning.Add(other.gameObject);
        }
    }
Ejemplo n.º 6
0
        public bool HandleCommand(TankGameLogicProcessor process, GamePlayer player, GSPacketIn packet)
        {
            if (player.CurrentGame.Data.CurrentIndex == player && player.CurrentGame.Data.Players[player].State != TankGameState.DEAD)
            {
                if (player.CurrentGame.Data.CurrentFire == null)
                {
                    player.CurrentGame.Data.CurrentFire = player;
                }

                int x = packet.ReadInt();
                int y = packet.ReadInt();

                if (Math.Abs(player.CurrentGame.Data.Players[player].X - x) > 100)
                {
                    //player.Out.SendMessage(eMessageType.ALERT, LanguageMgr.GetTranslation("Game.Server.SceneGames.TankHandle"));
                    StatMgr.LogErrorPlayer(player.PlayerCharacter.ID, player.PlayerCharacter.UserName, player.PlayerCharacter.NickName,
                                           ItemRemoveType.FireError, player.CurrentGame.Data.Players[player].X.ToString() + " to " + x.ToString() + ",MapID:" + player.CurrentGame.Data.MapIndex);
                    player.Client.Disconnect();
                    return(false);;
                }

                int force = packet.ReadInt();
                int angle = packet.ReadInt();

                TankData   data  = player.CurrentGame.Data;
                Tile       shape = Managers.BallMgr.FindTile(data.CurrentBall.ID);
                GSPacketIn pkg   = new GSPacketIn((byte)ePackageType.GAME_CMD, player.PlayerCharacter.ID);
                pkg.WriteByte((byte)TankCmdType.FIRE);
                pkg.WriteInt(data.AddBall);
                for (int i = 0; i < data.AddBall; i++)
                {
                    if (player.CurrentGame.Data.ReduceFireBombs)
                    {
                        if (data.IsFastSpeed())
                        {
                            StatMgr.LogErrorPlayer(player.PlayerCharacter.ID, player.PlayerCharacter.UserName, player.PlayerCharacter.NickName,
                                                   ItemRemoveType.FastError, "MapID:" + player.CurrentGame.Data.MapIndex);
                            player.Client.Disconnect();
                            return(false);;
                        }

                        data.FireLogin = true;
                        double reforce = 1;
                        int    reangle = 0;
                        if (i == 1)
                        {
                            reforce = 0.9;
                            reangle = -5;
                        }
                        else if (i == 2)
                        {
                            reforce = 1.1;
                            reangle = 5;
                        }

                        int vx = (int)(force * reforce * Math.Cos((double)(angle + reangle) / 180 * Math.PI));
                        int vy = (int)(force * reforce * Math.Sin((double)(angle + reangle) / 180 * Math.PI));

                        data.PhyID++;

                        BombObject bomb = new BombObject(data.PhyID, BallMgr.GetBallType(data.CurrentBall.ID), data.Players[player], shape, data.CurrentBall.Radii, data.AddMultiple < 1,
                                                         data.CurrentBall.Mass, data.CurrentBall.Weight, data.CurrentBall.Wind, data.CurrentBall.DragIndex, data.BallPower);

                        bomb.SetXY(x, y);
                        bomb.setSpeedXY(vx, vy);
                        data.CurrentMap.AddPhysical(bomb);
                        pkg.WriteBoolean(bomb.IsHole);
                        pkg.WriteInt(bomb.Id);
                        pkg.WriteInt(x);
                        pkg.WriteInt(y);
                        pkg.WriteInt(vx);
                        pkg.WriteInt(vy);
                        pkg.WriteInt(bomb.Actions.Count);
                        foreach (BombAction action in bomb.Actions)
                        {
                            pkg.WriteInt(action.TimeInt);
                            pkg.WriteInt(action.Type);
                            pkg.WriteInt(action.Param1);
                            pkg.WriteInt(action.Param2);
                            pkg.WriteInt(action.Param3);
                            pkg.WriteInt(action.Param4);
                        }

                        data.SetRunTime((int)bomb.RunTime);
                    }
                }

                player.CurrentGame.SendToAll(pkg);

                data.FireLogin = false;
                if (data.Bombs || data.Players[player].State == TankGameState.DEAD)
                {
                    data.TotalDelay += data.CurrentBall.Delay;
                    process.SendArk(player.CurrentGame, player);
                    player.PropInventory.AddItemTemplate(PropItemMgr.GetRandomFightProp(data.MapIndex));
                    data.Players[player].SetDander(20);

                    process.SendPlayFinish(player.CurrentGame, player);
                    //GSPacketIn pkgMsg = new GSPacketIn((byte)ePackageType.GAME_CMD);
                    //pkgMsg.WriteByte((byte)TankCmdType.PLAYFINISH);
                    //pkgMsg.WriteInt(player.CurrentGame.Data.TurnNum);
                    //player.CurrentGame.SendToAll(pkgMsg);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 7
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //doesn't damage the player
        /*tentacle attack player*/

        /*if (other.gameObject.GetComponent<PlayerGridObject>())
         * {
         *  other.gameObject.GetComponent<PlayerGridObject>().TakeDamage(1);
         *  boss.touchedPlayer = true;
         * }*/

        /*player plants attack tentacle*/


        if (other.gameObject.GetComponent <PlantGridObject>() && boss.hp != 0)
        {
            if (((other.gameObject.GetComponent <WatermelonPlantObject>() || other.gameObject.GetComponent <PlantProjectileObject>()) && tentacleNum == 0) || //watermelon
                (other.gameObject.GetComponent <TurbinePlantObject>() && tentacleNum == 1) ||                                                                 //turbine
                (other.gameObject.GetComponent <CactusPlantObject>() && tentacleNum == 2) ||                                                                  //cactus
                ((other.gameObject.GetComponent <BombPlantObject>() || other.gameObject.GetComponent <BombObject>()) && tentacleNum == 3) ||                  //bomb
                (other.gameObject.GetComponent <LightPlantObject>() && tentacleNum == 4) ||                                                                   //mushroom
                ((other.gameObject.GetComponent <BoomerangPlantObject>() || other.gameObject.GetComponent <Boomerang>()) && tentacleNum == 5) ||              //boomerang
                (other.gameObject.GetComponent <SpinningPlant>() && tentacleNum == 6))                                                                        //spinning
            {
                if (anim)
                {
                    anim.Play("Damaged");
                }

                //play damaged animation for tentacle?
                boss.touchedPlayer = true; //makes tentacles retract
                if (!boss.spawnedMe)
                {
                    Instantiate(weedBoss, new Vector3(Random.Range(-4.5f, 4.5f), Random.Range(-3.5f, 3.5f), 0), spawnRotation);
                }
            }
            else
            {
                spawnPosition = new Vector3(other.gameObject.transform.position.x, other.gameObject.transform.position.y, 0f);
                if (other.gameObject.GetComponent <WatermelonPlantObject>())
                {
                    if (!other.gameObject.GetComponent <WatermelonPlantObject>().evil)
                    {
                        Destroy(other.gameObject);
                        Instantiate(evilWatermelonPlant, spawnPosition, spawnRotation);
                    }
                }
                if (other.gameObject.GetComponent <TurbinePlantObject>())
                {
                    if (!other.gameObject.GetComponent <TurbinePlantObject>().evil)
                    {
                        Destroy(other.gameObject);
                        Instantiate(evilTurbinePlant, spawnPosition, spawnRotation);
                    }
                }
                if (other.gameObject.GetComponent <CactusPlantObject>())
                {
                    if (!other.gameObject.GetComponent <CactusPlantObject>().evil)
                    {
                        Destroy(other.gameObject);
                        Instantiate(evilCactusPlant, spawnPosition, spawnRotation);
                    }
                }
                if (other.gameObject.GetComponent <BoomerangPlantObject>())
                {
                    if (!other.gameObject.GetComponent <BoomerangPlantObject>().evil)
                    {
                        Destroy(other.gameObject);
                        Instantiate(evilBoomerangPlant, spawnPosition, spawnRotation);
                    }
                }
                if (other.gameObject.GetComponent <BombPlantObject>())
                {
                    if (!other.gameObject.GetComponent <BombPlantObject>().evil)
                    {
                        if (other.gameObject.GetComponent <BombPlantObject>().bomb)
                        {
                            Destroy(other.gameObject.GetComponent <BombPlantObject>().bomb.gameObject);
                        }
                        Destroy(other.gameObject);
                        Instantiate(evilBombPlant, spawnPosition, spawnRotation);
                    }
                    else
                    {
                        BombObject temp = other.gameObject.GetComponent <BombPlantObject>().bomb;
                        if (temp)
                        {
                            temp.Roll(realDir);
                        }
                    }
                }
                if (other.gameObject.GetComponent <LightPlantObject>())
                {
                    if (!other.gameObject.GetComponent <LightPlantObject>().evil)
                    {
                        Destroy(other.gameObject);
                        Instantiate(evilLightPlant, spawnPosition, spawnRotation);
                    }
                    else
                    {
                        CircuitSystem cs = FindObjectOfType <CircuitSystem>();
                        cs.isLit = true;
                        cs.ConnectJunction();
                    }
                }
                if (other.gameObject.GetComponent <SpinningPlant>())
                {
                    if (!other.gameObject.GetComponent <SpinningPlant>().evil)
                    {
                        Destroy(other.gameObject);
                        Instantiate(evilSpinningPlant, spawnPosition, spawnRotation);
                    }
                }
            }
        }
    }
    public virtual void Attack()
    {
        if (!Globals.canvas.dialogue)
        {
            hitSomething = false;

            if (audioSource != null)
            {
                audioSource.clip = attackSound;
                audioSource.Play();
            }
            switch (direction)
            {
            case Globals.Direction.South:
                killList = southHitCollider.GetKillList();
                break;

            case Globals.Direction.East:
                killList = eastHitCollider.GetKillList();
                break;

            case Globals.Direction.North:
                killList = northHitCollider.GetKillList();
                break;

            case Globals.Direction.West:
                killList = westHitCollider.GetKillList();
                break;
            }

            /*
             * Clear all dead targets in killList.
             * This uses lambda syntax: if a KillableGridObject in
             * the list is null, then remove it.
             */
            killList.RemoveAll((KillableGridObject target) => target == null);

            // Deal damage to all targets of the enemy faction
            foreach (KillableGridObject target in killList)
            {
                if (target.faction != this.faction)
                {
                    hitSomething = true;
                    target.TakeDamage(damage);
                }
                if (this.GetComponent <PlayerGridObject>())
                {
                    BombObject bomb = target.GetComponent <BombObject>();

                    if (bomb && !bomb.evil)
                    {
                        bomb.Roll(direction);
                    }
                    //deplant code MOVED so deplanting is a different button

                    /*PlantGridObject plant = target.GetComponent<PlantGridObject>();
                     * if (plant) {
                     *  plant.TakeDamage(100);
                     * }*/
                }
            }
        }
    }