Exemplo n.º 1
0
    protected void Fire(string strProjectileName, Vector3 position, Vector3 direction)
    {
        string strFunction = "IAIBase::Fire()";

        GameObject goProjectile;

        if (m_dictProjectilePrefabs.TryGetValue(strProjectileName, out goProjectile))
        {
            CProjectile cProjectile = goProjectile.GetComponent <CProjectile>();
            if (null == cProjectile)
            {
                Debug.LogError(string.Format("{0} {1}: {2}", strFunction, ErrorStrings.ERROR_MISSING_COMPONENT, typeof(CProjectile).ToString()));
                return;
            }

            cProjectile.Direction      = new Vector3(direction.x, direction.y - 0.1f, direction.z);
            cProjectile.Instantiator   = gameObject;
            cProjectile.Activation     = true;
            cProjectile.FiringPosition = position;
            goProjectile.name          = strProjectileName;

            // Select a gun position.
            Vector3 v3GunPosition = m_rggoGuns[Random.Range(0, m_rggoGuns.Length - 1)].transform.position;

            Instantiate(goProjectile, v3GunPosition, goProjectile.transform.rotation);

            m_dictInventory[strProjectileName]--;
        }
        else
        {
            Debug.LogError("Unrecognised projectile name: " + strProjectileName);
        }
    }
Exemplo n.º 2
0
 public virtual void OnHit(CProjectile Projectile, SWIGTYPE_p_Vector3 Direction)
 {
     testPINVOKE.CBuilding_OnHit__SWIG_0(swigCPtr, CProjectile.getCPtr(Projectile), SWIGTYPE_p_Vector3.getCPtr(Direction));
     if (testPINVOKE.SWIGPendingException.Pending)
     {
         throw testPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 3
0
    public void Randomize(float value)
    {
        rof      = Random.Range(0.01f, value * 0.02f);
        lifetime = Random.Range(1, value);
        CProjectile proj = projectile.GetComponent <CProjectile>();

        proj.speed       = Random.Range(50, value * 4);
        proj.damage      = Random.Range(1, value);
        proj.spreadRange = Random.Range(0.1f, value * 0.01f);
    }
Exemplo n.º 4
0
    public void Randomize(float value)
    {
        rof      = Random.Range(0.01f, value * 0.02f);
        lifetime = Random.Range(1, value);
        GameObject.FindGameObjectWithTag("ScoreKeeper").GetComponent <CScoreData>().pickupTimer = lifetime;
        CProjectile proj = projectile.GetComponent <CProjectile>();

        proj.speed       = Random.Range(50, value * 4);
        proj.damage      = Random.Range(1, value);
        proj.spreadRange = Random.Range(0.1f, value * 0.01f);
    }
Exemplo n.º 5
0
    /////////////////////////////////////////////////////////////////////////////
    /// Function:               UpdateWeapons
    /////////////////////////////////////////////////////////////////////////////
    public void UpdateWeapons()
    {
        string strFunction = "CPowerUpSO::UpdateWeapons()";

        // Clear the objects list.
        m_dictWeapons = new Dictionary <string, GameObject>();

        // Add stuff to it.
        for (int i = 0; i < m_rggoWeapons.Length; ++i)
        {
            // Get a handle on the item script
            CProjectile cProjectile = m_rggoWeapons[i].GetComponent <CProjectile>();
            if (null == cProjectile)
            {
                Debug.LogError(string.Format("{0} {1}: {2}", strFunction, ErrorStrings.ERROR_MISSING_COMPONENT, typeof(CProjectile).ToString()));
                continue;
            }

            string strName = "";

            switch (cProjectile.ProjectileType)
            {
            case CProjectile.EProjectileType.PROJECTILE_BULLET:

                strName = Names.NAME_BULLET;

                break;

            case CProjectile.EProjectileType.PROJECTILE_MISSILE:

                strName = Names.NAME_MISSILE;

                break;

            case CProjectile.EProjectileType.PROJECTILE_RAY:

                strName = Names.NAME_RAY;

                break;

            default:
                Debug.LogError(string.Format("{0} {1}: {2}", strFunction, ErrorStrings.ERROR_UNASSIGNED_TYPE, cProjectile.ProjectileType.ToString()));
                continue;
            }

            // Add weapon to dictionary.
            m_dictWeapons.Add(strName, m_rggoWeapons[i]);
        }
    }
Exemplo n.º 6
0
        protected void Fire(string projectileName, Vector3 position, Vector3 direction)
        {
            GameObject goProjectile;

            if (projectilePrefabs.TryGetValue(projectileName, out goProjectile))
            {
                CProjectile cProjectile = goProjectile.GetComponent <CProjectile>();

                cProjectile.Direction      = direction;
                cProjectile.Instantiator   = gameObject;
                cProjectile.Activation     = true;
                cProjectile.FiringPosition = position;
                goProjectile.name          = Names.NAME_BULLET;

                Instantiate(goProjectile, gun.transform.position, goProjectile.transform.rotation);
            }
            else
            {
                Debug.LogError("Unrecognised projectile name");
            }
        }
Exemplo n.º 7
0
 public virtual void OnKill(CPlayer PlayerKilled, CProjectile Projectile)
 {
     testPINVOKE.CBuilding_OnKill__SWIG_0(swigCPtr, CPlayer.getCPtr(PlayerKilled), CProjectile.getCPtr(Projectile));
 }
Exemplo n.º 8
0
 internal static HandleRef getCPtr(CProjectile obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Exemplo n.º 9
0
 public void RegisterEvent(CPlayer Owner, MISSION_TYPE MissionType, CPlayer PlayerKilled, CInventoryItem InventoryItem, CProjectile Projectile)
 {
     testPINVOKE.CMissionManager_RegisterEvent__SWIG_1(swigCPtr, CPlayer.getCPtr(Owner), (int)MissionType, CPlayer.getCPtr(PlayerKilled), CInventoryItem.getCPtr(InventoryItem), CProjectile.getCPtr(Projectile));
 }
Exemplo n.º 10
0
 public void OnKill(CPlayer PlayerKilled, CProjectile Projectile)
 {
     testPINVOKE.CPlayerPimpl_OnKill__SWIG_0(swigCPtr, CPlayer.getCPtr(PlayerKilled), CProjectile.getCPtr(Projectile));
 }
Exemplo n.º 11
0
    /////////////////////////////////////////////////////////////////////////////
    /// Function:               OnCollisionEnter
    /////////////////////////////////////////////////////////////////////////////
    protected void OnCollisionEnter(Collision cCollision)
    {
        // For error reporting.
        string strfunctionName = "IAIBase::OnCollisionEnter()";

        // Get a handle on the gameObject with which we collided.
        GameObject goObject = cCollision.gameObject;

        // Check if we collided with a base, and act accordingly depending on the
        //  team.
        if (goObject.tag == Tags.TAG_BASE)
        {
            if (goObject.name == Names.NAME_RED_BASE && m_eTeam == ETeam.TEAM_RED)
            {
                CollidedWithBase();
            }
            else if (goObject.name == Names.NAME_BLUE_BASE && m_eTeam == ETeam.TEAM_BLUE)
            {
                CollidedWithBase();
            }
        }

        // Depending on the name of the object, react accordingly.
        switch (goObject.tag)
        {
        case Tags.TAG_WEAPON:

            // Get the name and team of the attacker using its projectile.
            CProjectile cProjectile = goObject.GetComponent <CProjectile>();

            m_fHealth -= cProjectile.Damage;

            // We've been attacked by an enemy, flag this fact.
            m_bIsBeingAttacked = true;

            if (null == cProjectile.Instantiator.gameObject)
            {
                return;
            }

            string strAttackerName = "";
            ETeam  eTeam           = ETeam.TEAM_NONE;

            if (cProjectile.Instantiator.tag == Tags.TAG_PLAYER)
            {
                // We have been hit by a player, get the playercontroller.
                PlayerController cPlayerController = cProjectile.Instantiator.GetComponent <PlayerController>();
                if (null == cPlayerController)
                {
                    Debug.LogError(string.Format("{0} {1}: {2}", strfunctionName, ErrorStrings.ERROR_MISSING_COMPONENT, typeof(PlayerController).ToString()));
                    return;
                }

                // Get the network player. We're going to compare this to the ClientDataOnServer object.
                NetworkPlayer cNetworkPlayer = cPlayerController.networkView.owner;

                if (Network.isServer)
                {
                    ServerManager serverManager = RoleManager.roleManager as ServerManager;
                    foreach (ClientDataOnServer clientData in serverManager.RegisteredClients)
                    {
                        if (cNetworkPlayer == clientData.NetworkPlayer)
                        {
                            strAttackerName = clientData.Profile.DisplayName;
                        }

                        eTeam = clientData.ClientTeam;
                    }
                }
            }
            else
            {
                // This is not a player, we can just set the name.
                strAttackerName = cProjectile.Instantiator.gameObject.name;

                // Find the team using the attacker's name.
                if (strAttackerName == Names.NAME_AI_DRONE_BLUE)
                {
                    eTeam = ETeam.TEAM_BLUE;
                }

                else if (strAttackerName == Names.NAME_AI_DRONE_RED)
                {
                    eTeam = ETeam.TEAM_RED;
                }
            }



            m_Attacker = new CAttacker()
            {
                AttackerName = strAttackerName, Team = eTeam
            };

            break;
        }
    }
Exemplo n.º 12
0
 public void RemoveProjectile(CProjectile Projectile)
 {
     testPINVOKE.CMagazine_RemoveProjectile(swigCPtr, CProjectile.getCPtr(Projectile));
 }
Exemplo n.º 13
0
        private void OnCollisionEnter(Collision cCollision)
        {
            // Only react on server and results will be send to client when processed
            if (Network.isServer)
            {
                // Get a handle on the gameObject with which we collided.
                GameObject goObject = cCollision.gameObject;

                // Check if we collided with a base
                if (goObject.tag == Tags.TAG_BASE)
                {
                    ClientDataOnServer client = serverManager.RegisteredClients.First(c => c.NetworkPlayer == networkView.owner);

                    if (goObject.name == Names.NAME_RED_BASE && client.ClientTeam == IAIBase.ETeam.TEAM_RED)
                    {
                        CollidedWithBase(client);
                    }
                    else if (goObject.name == Names.NAME_BLUE_BASE && client.ClientTeam == IAIBase.ETeam.TEAM_BLUE)
                    {
                        CollidedWithBase(client);
                    }
                }

                // Depending on the name of the object, react accordingly.
                switch (goObject.tag)
                {
                case Tags.TAG_WEAPON:

                    // Get the name and team of the attacker using its projectile.
                    CProjectile cProjectile = goObject.GetComponent <CProjectile>();

                    if (null == cProjectile.Instantiator.gameObject)
                    {
                        return;
                    }

                    //// Set the name.
                    string        strAttackerName = "";
                    IAIBase.ETeam eTeam           = IAIBase.ETeam.TEAM_NONE;

                    // Check if attacker is another client
                    GameObject       goAttacker = cProjectile.Instantiator;
                    PlayerController aPC        = goAttacker.GetComponent <PlayerController>();
                    if (aPC != null)
                    {
                        ClientDataOnServer cd = serverManager.RegisteredClients.First(c => c.NetworkPlayer == aPC.networkView.owner);
                        strAttackerName = cd.Profile.DisplayName;
                        eTeam           = cd.ClientTeam;
                    }
                    else     // attacker is an AI
                    {
                        strAttackerName = "AI";
                        //// Find the team using the attacker's name.
                        if (strAttackerName == Names.NAME_AI_DRONE_BLUE + "(Clone)")
                        {
                            eTeam = IAIBase.ETeam.TEAM_BLUE;
                        }

                        else if (strAttackerName == Names.NAME_AI_DRONE_RED + "(Clone)")
                        {
                            eTeam = IAIBase.ETeam.TEAM_RED;
                        }
                    }

                    serverManager.SendGameMessage(new PlayerTakenDamage()
                    {
                        Player = networkView.owner, PlayerPosition = transform.position, Damage = (int)cProjectile.Damage, Attacker = strAttackerName, AttackerTeam = eTeam
                    });

                    break;
                }
            }
        }