Ejemplo n.º 1
0
    void CheckFireGun()
    {   //for now, it defaults to bouncy. Later should add capability for multiple shot types.
        if (Input.GetKey(FireButton) && CanFire())
        {
            Quaternion qt;
            Vector3    pos;

            if (BulletSpawnLoc != null)
            {
                qt  = BulletSpawnLoc.transform.rotation;
                pos = BulletSpawnLoc.transform.position;
            }
            else
            {
                qt  = new Quaternion();
                pos = Vector3.zero;
            }

            CreateProjectileMsg msg = new CreateProjectileMsg(true, Time.frameCount, OwningTank.GetComponent <TankBody>().GetTankID(),
                                                              ShotType.Bouncy,
                                                              pos, qt);
            GameUtilities.Broadcast("CreateProjectile", msg);
            FrameFired = Time.frameCount;
        }
    }
Ejemplo n.º 2
0
 private void FailLevel()
 {
     GameUtilities.Broadcast("DisableMovement", "");
     TimerText.text = "RIP";
     FailureText.gameObject.SetActive(true);
     Invoke("EndLevel", 5.0f);
 }
Ejemplo n.º 3
0
 public void StartGame()
 {
     GameUtilities.Broadcast(
         "LoadNext",
         new LoadNextSceneMsg(SceneName.Level)
         );
 }
Ejemplo n.º 4
0
 private void EndLevel()
 {
     GameUtilities.Broadcast(
         "LoadNext",
         new LoadNextSceneMsg(SceneName.Title)
         );
 }
Ejemplo n.º 5
0
 void CheckMoveTank()
 {
     if (Input.GetKey(Forward))
     {   //forward
         TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, true);
         GameUtilities.Broadcast("MoveTank", msg);
     }
     if (Input.GetKey(Backward))
     {   //backward
         TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, false);
         GameUtilities.Broadcast("MoveTank", msg);
     }
 }
Ejemplo n.º 6
0
 void CheckStrafeTank()
 {
     if (Input.GetKey(StrafeLeft))
     {
         TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, true);
         GameUtilities.Broadcast("StrafeTank", msg);
     }
     if (Input.GetKey(StrafeRight))
     {
         TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, false);
         GameUtilities.Broadcast("StrafeTank", msg);
     }
 }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (IsDead())
        {
            EnemyIDMsg msg = new EnemyIDMsg(EnemyID, EType);
            GameUtilities.Broadcast("DestroyThisEnemy", msg);
        }

        PassiveUpdatePlayerAggro();
        AttackMaxAggroPlayer();

        //LookAtTestPlayer();
    }
Ejemplo n.º 8
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Semicolon))
        {
            DamageTankMsg msg = new DamageTankMsg(0, CurrentFrame, 20.0f);
            GameUtilities.Broadcast("DamageTank", msg);
        }

        if (health <= 0.0f)
        {
            FailLevel();
        }
    }
Ejemplo n.º 9
0
 void CheckTurnTank()
 {
     if (Input.GetKey(Left))
     {
         TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, false);
         GameUtilities.Broadcast("TurnTank", msg);
         MarkSyncNeeded();
     }
     if (Input.GetKey(Right))
     {
         TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, true);
         GameUtilities.Broadcast("TurnTank", msg);
         MarkSyncNeeded();
     }
 }
Ejemplo n.º 10
0
 void CheckVerticalMove()
 {
     if (Input.GetKey(Up))
     {
         TankComponentMovementMsg msg = new TankComponentMovementMsg(OwningTank.GetComponent <TankBody>().TankID,
                                                                     Time.frameCount, true);
         GameUtilities.Broadcast("MoveGunVertical", msg);
     }
     if (Input.GetKey(Down))
     {
         TankComponentMovementMsg msg = new TankComponentMovementMsg(OwningTank.GetComponent <TankBody>().TankID,
                                                                     Time.frameCount, false);
         GameUtilities.Broadcast("MoveGunVertical", msg);
     }
 }
Ejemplo n.º 11
0
 void CheckHorizontalMove()
 {
     if (Input.GetKey(Right))
     {
         TankComponentMovementMsg msg = new TankComponentMovementMsg(OwningTank.GetComponent <TankBody>().TankID,
                                                                     Time.frameCount, true);
         GameUtilities.Broadcast("MoveGunHorizontal", msg);
     }
     if (Input.GetKey(Left))
     {
         TankComponentMovementMsg msg = new TankComponentMovementMsg(OwningTank.GetComponent <TankBody>().TankID,
                                                                     Time.frameCount, false);
         GameUtilities.Broadcast("MoveGunHorizontal", msg);
     }
 }
Ejemplo n.º 12
0
    void OnCollisionEnter(Collision collision)
    {
        if ((NoCollisions > MaxNoCollisions && !PlayerFriendly) || ((NoCollisions > MaxNoCollisions - PlayerCollisionPenalty) && PlayerFriendly))
        {
            Destroy(gameObject);
        }
        NoCollisions++;
        if (collision.transform.CompareTag("Player"))
        {
            print("Player Hit");
            if (!PlayerFriendly)
            {
                DamageTankMsg msg = new DamageTankMsg();
                msg.Amount  = Damage;
                msg.FrameNo = Time.frameCount;
                msg.TankID  = collision.transform.gameObject.GetComponent <TankBody>().GetTankID();

                GameUtilities.Broadcast("DamageTank", msg);
                Destroy(gameObject);
            }
        }
        else if (collision.transform.CompareTag("Enemies"))
        {
            print("Enemy Hit");
            if (PlayerFriendly)
            {
                DamageEnemyMsg msg = new DamageEnemyMsg();
                msg.Amount  = Damage;
                msg.TankID  = CreatingPLayer;
                msg.EType   = collision.transform.parent.gameObject.GetComponent <Guardian>().GetEnemyType();
                msg.EnemyID = collision.transform.parent.gameObject.GetComponent <Guardian>().EnemyID;

                GameUtilities.Broadcast("DamageEnemy", msg);
                Destroy(gameObject);
            }
        }

        if (!PlayerFriendly)
        {
            Damage -= 2;            //MAGIC NUMBER guardians are stupid so they have reduced penalty \
            gameObject.GetComponent <MeshRenderer>().material.color /= 8;
        }
        else
        {
            Damage /= 2;            //MAGIC NUMBER so players can exploit bouncing shots too badly
            gameObject.GetComponent <MeshRenderer>().material.color /= 8;
        }
    }
Ejemplo n.º 13
0
    void CheckTouchingPlayer()
    {
        if (collectableCollider.bounds.Intersects(playerCollider.bounds)) //check for intersection with Player
                                                                          //player and collectables don't collide with each other
        {
            // GetCollectable();
            collectableObject.SetActive(false);
            CollectablesLeft--;


            if (CollectablesLeft <= 0)
            {
                IsFinishActiveMsg msg = new IsFinishActiveMsg(true);
                GameUtilities.Broadcast("SetIsFinishActive", msg);
            }
        }
    }
Ejemplo n.º 14
0
 public void DamageTestEnemyGuardian()
 {
     if (TestEnemyGuardian != null && Input.GetKey(KeyCode.P) && CanFire())
     {
         print("Attacken thha enermy!");
         //public EnemyType EType;
         //public byte EnemyID;
         //public byte TankID;//the tank this damage is from
         //public float Amount;
         DamageEnemyMsg msg = new DamageEnemyMsg();
         msg.EnemyID = TestEnemyGuardian.GetComponent <Guardian>().EnemyID;
         msg.TankID  = OwningTank.GetComponent <TankBody>().TankID;
         msg.EType   = EnemyType.Guardian;
         msg.Amount  = 10f;
         GameUtilities.Broadcast("DamageEnemy", msg);
         FrameFired = Time.frameCount;
     }
 }
Ejemplo n.º 15
0
 // Update is called once per frame
 void FixedUpdate()
 {
     CurrentFrame = Time.frameCount;
     //madbrew : what about order on recieving end?
     MoveTank();
     HealStamina();
     if (CurrentFrame == NextMoveUpdateFrame)
     {
         NextMoveUpdateFrame = LastMoveUpdateFrame;
         SyncTankPositionMsg msg = new SyncTankPositionMsg(
             CurrentFrame,
             TankID,
             transform.position,
             transform.rotation
             );
         GameUtilities.Broadcast("SyncTankPosition", msg);
     }
 }
Ejemplo n.º 16
0
    void AttackMaxAggroPlayer()
    {   //Attack the max aggro player, if their aggro is greater than 3 (MAGIC NUMBER)
        GameObject MaxAggroPlayer = FindMaxAggroPlayer();

        if (MaxAggroPlayer == null)
        {
            return;
        }

        transform.LookAt(MaxAggroPlayer.transform);
        if (CanFire())
        {
            Quaternion qt;
            Vector3    pos;

            if (BulletSpawnLoc != null)
            {
                qt  = BulletSpawnLoc.transform.rotation;
                pos = BulletSpawnLoc.transform.position;
            }
            else
            {
                qt  = new Quaternion();
                pos = Vector3.zero;
            }

            CreateProjectileMsg msg = new CreateProjectileMsg(
                false,
                Time.frameCount,
                GameUtilities.INVALID_TANK_ID,
                ShotType.Bouncy,
                pos,
                qt
                );
            GameUtilities.Broadcast("CreateProjectile", msg);
            FrameFired = Time.frameCount;
        }
    }
Ejemplo n.º 17
0
    private void UpdateHealthOrStamina(float currentValue, float minValue, float maxValue, int barID)
    {
        UpdateBar msg = new UpdateBar(currentValue, minValue, maxValue, barID);

        GameUtilities.Broadcast("HandleBar", msg);
    }
Ejemplo n.º 18
0
    void ReceivePacket(string data)
    {
        GameObject OwningGame = null;

        GameUtilities.FindGame(ref OwningGame);
        string[] data_pair     = data.Split(new char[] { ',' }, 2);
        string   descriminator = data_pair[0];
        string   payload       = data_pair[1];

        switch (int.Parse(descriminator))
        {
        case LoadNextID:
            GameUtilities.Broadcast("LoadNext", ReconstructLoadNextSceneMsg(payload));
            break;

        case MoveGunVerticalID:
            GameUtilities.Broadcast("MoveGunVertical", ReconstructTankComponentMovementMsg(payload));
            break;

        case MoveGunHorizontalID:
            GameUtilities.Broadcast("MoveGunHorizontal", ReconstructTankComponentMovementMsg(payload));
            break;

        case MoveTankID:
            GameUtilities.Broadcast("MoveTank", ReconstructTankComponentMovementMsg(payload));
            break;

        case TurnTankID:
            GameUtilities.Broadcast("TurnTank", ReconstructTankComponentMovementMsg(payload));
            break;

        case StrafeTankID:
            GameUtilities.Broadcast("StrafeTank", ReconstructTankComponentMovementMsg(payload));
            break;

        case CreateProjectileID:
            GameUtilities.Broadcast("CreateProjectile", ReconstructCreateProjectileMsg(payload));
            break;

        case DamageTankID:
            GameUtilities.Broadcast("DamageTank", ReconstructDamageTankMsg(payload));
            break;

        case DamageEnemyID:
            GameUtilities.Broadcast("DamageEnemy", ReconstructDamageEnemyMsg(payload));
            break;

        case DestroyThisEnemyID:
            GameUtilities.Broadcast("DestroyThisEnemy", ReconstructEnemyIDMsg(payload));
            break;

        case SetIsFinishActiveID:
            GameUtilities.Broadcast("SetIsFinishActive", ReconstructSetIsFinishActiveMsg(payload));
            break;

        case UpdateCollectableTextID:
            GameUtilities.Broadcast("UpdateCollectableText", ReconstructUpdateCollectableTextMsg(payload));
            break;

        case SyncTankPositionID:
            GameUtilities.Broadcast("SyncTankPosition", ReconstructSyncTankPositionMsg(payload));
            break;

        default:
            // No-op?
            break;
        }
    }