Beispiel #1
0
    private void RpcProjectileVisuels(int shipThatFiredNID, int targetShipNID)
    {
        ShipControl2 shipFired  = GetShipCtrl(shipThatFiredNID);
        ShipControl2 targetShip = GetShipCtrl(targetShipNID);

        GFX.ProjectileVisuels(shipFired, targetShip);
    }
Beispiel #2
0
    public void OnTriggerStay2D(Collider2D other)
    {
        //Has a target, no need to look for another
        if (hasTarget)
        {
            //removing a target is handled in the AI
            return;
        }

        //No target; look for ship.
        //is "other" a ship?
        ShipControl2 otherShip = other.GetComponent <ShipControl2>();

        if (otherShip == null)
        {
            Debug.LogError("Detecting a something that wasnt a ship");
            return;
        }
        //is it on my team??
        if (otherShip.cliantNID != cliantNID)
        {
            currentTargetSC = otherShip;
            targetNID       = otherShip.shipNID;
            hasTarget       = true;
            Debug.DrawLine(transform.position, otherShip.transform.position, Color.green);
        }
    }
Beispiel #3
0
    private void DeselectTarget()
    {
        currentTargetSC = null;
        targetNID       = 0;
        hasTarget       = false;

        Debug.DrawLine(transform.position, Vector3.zero, Color.red);
    }
Beispiel #4
0
    //custom functions
    public void PooledObject_Setup(ShipControl2 _target)
    {
        target    = _target.transform;
        targetSC  = _target;
        targetNID = _target.shipNID;

        targetSC.CB_RegesterOnShipRemoval(OnTargetRemoved);
    }
Beispiel #5
0
    public void FireProjectile(ShipControl2 shipThatFiredSC, ShipControl2 targetShipSC, int damage, float delay)
    {
        if (!targetShipSC.gameObject.activeSelf)
        {
            return;
        }
        //Create Visuels -- cliants
        RpcProjectileVisuels(shipThatFiredSC.shipNID, targetShipSC.shipNID);

        //Queue up Damage -- damage
        targetShipSC.TakeDelayedDamage(damage, delay);
    }
Beispiel #6
0
    public ShipControl2 GetShipCtrl(int shipNID)
    {
        //Debug.Log("Looking up: " + shipNID.ToString());
        ShipControl2 sausages = null;

        allActiveShips.TryGetValue(shipNID, out sausages);

        //if (sausages == null)
        //    Debug.Log("Missing Ship; cant find ship with ID; " + shipNID.ToString() + ". Total IDs in Dict: " + allActiveShips.Count.ToString());

        return(sausages);
    }
Beispiel #7
0
    //custom functions
    public void ProjectileVisuels(ShipControl2 shipFired, ShipControl2 targetShip)
    {
        if (shipFired == null || targetShip == null)
        {
            Debug.Log("(cosmetic) Cant Fire as one of the ships is destroyed.");
            return;
        }

        GameObject newProj = ProjectilePool();

        newProj.transform.position = shipFired.transform.position;
        newProj.GetComponent <Projectile>().PooledObject_Setup(targetShip);
    }
Beispiel #8
0
    public void CmdCreateShip(Vector3 pos, float angle, string playerNID, Color colour)
    {
        //NewShip
        GameObject newShipObj = CustomSpawnManager.Instance.GetFromPool(pos);

        newShipObj.transform.rotation = Quaternion.Euler(0.0f, 0.0f, angle);
        ShipControl2 ship = newShipObj.GetComponent <ShipControl2>();

        ship.cliantNID       = playerNID;
        ship.shipNID         = ++shipIdentifyer;
        ship.hitPoints       = StartingVariables.shipHP;
        ship.shieldHitPoints = StartingVariables.shipShieldHP;
        ship.shipSpeed       = new Vector3(0, StartingVariables.shipSpeed, 0);
        ship.colour          = colour;

        ship.StartAI();
        NetworkServer.Spawn(newShipObj, CustomSpawnManager.Instance.assetId);
    }
Beispiel #9
0
 // Custom Functions
 public void RegesterShip(int shipNID, ShipControl2 shipCtrl)
 {
     allActiveShips.Add(shipNID, shipCtrl);
     //Debug.Log("Regestoring ship: " + shipNID );
 }