Ejemplo n.º 1
0
    public void Fire(Vector3 towards)
    {
        if (CustomNetworkManager.isServer)
        {
            return;
        }

        if (numArrowsLeft > 0)
        {
            Vector3 towardsFromTowerNonFlat = towards - arrowOrigin.position;
            Vector3 towardsFromTower        = new Vector3(towardsFromTowerNonFlat.x, 0, towardsFromTowerNonFlat.z); // Remove y-component
            Vector3 eulerDir = Quaternion.LookRotation(towardsFromTower).eulerAngles;

            // Send msg to server that we wish to fire an projectile and await broadcast from server before we spawn local copy
            Color             objColor   = calculateArrowColor();
            Vector3           arrowScale = calculateArrowScale();
            ProjectileDetails pDetails   = new ProjectileDetails()
            {
                dmg = damage, range = range
            };
            FireProjectileMsg msg = NetworkUtils.cFireProjectileMsg(ProjectileType.PlayerArrow, pDetails, arrowOrigin.position, eulerDir, arrowScale, speed, objColor, 8);
            NetworkManager.singleton.client.Send((short)CustomProtocol.FireProjectile, msg);

            numArrowsLeft -= 1;
        }
    }
Ejemplo n.º 2
0
    private void UpdateDetails(ProjectileDetails details)
    {
        _details = details;

        _tr.position   = _details.CasterTransform.position;
        _tr.localScale = _details.Scale;
        _spriteComponent.UpdateSprite(_details.Artwork);
    }
Ejemplo n.º 3
0
        private ProjectileDetails pd;   //stores the Projectile details in this form.

        public Projectile(int direction, GameObject projectile, ProjectileDetails pd)
        {
            this.direction  = direction;
            this.projectile = projectile;
            this.pd         = pd;
            locationX       = projectile.transform.position.x;
            locationY       = projectile.transform.position.y;
        }
Ejemplo n.º 4
0
 public static FireProjectileMsg cFireProjectileMsg(ProjectileType type, ProjectileDetails projDetails, Vector3 pos, Vector3 rot, Vector3 scale, float speed, Color color, uint id = 0)
 {
     return(new FireProjectileMsg()
     {
         type = type, objDetails = new SpawnedObject()
         {
             pos = pos, rot = rot, scale = scale, speed = speed, id = id, color = color
         },
         projDetails = projDetails
     });
 }
Ejemplo n.º 5
0
        public PlayerInfo(GameObject player)
        {
            isPrepFiring = 0;
            //set first melee to null to allow system to know it is not being used
            meele       = null;
            this.player = player;
            //get playerWidth and script
            this.playerWidth = player.GetComponent <BoxCollider2D>().size.y;
            this.pScript     = player.GetComponent <Player>();
            //get the details of firing a projectile as well as the cost of blocking
            pd            = new ProjectileDetails(pScript.projSpeed, pScript.setRangedAttack, pScript.setMeleeAttack);
            costManaBlock = pScript.manaBlock;
            //create the hit box of hitting enemy
            right1 = player.transform.FindChild("RightHitBox").gameObject;
            BoxCollider2D bcRight1 = right1.GetComponent <BoxCollider2D>();

            left1 = player.transform.FindChild("LeftHitBox").gameObject;
            BoxCollider2D bcLeft1 = left1.GetComponent <BoxCollider2D>();

            md    = new MeeleDetails(pScript.manaMelee, pScript.setMeleeAttack, bcLeft1.offset.x, bcLeft1.size.x, bcRight1.offset.x, bcRight1.size.x, bcLeft1.offset.y, bcLeft1.size.y, bcRight1.offset.y, bcRight1.size.y);
            fired = new ArrayList();
            Update();
        }
Ejemplo n.º 6
0
 public static FireProjectileMsg cFireProjectileMsg(ProjectileType type, ProjectileDetails projDetails, Transform trans, float speed, Color color, uint id = 0)
 {
     return(cFireProjectileMsg(type, projDetails, trans.position, trans.localEulerAngles, trans.localScale, speed, color, id));
 }
Ejemplo n.º 7
0
 public virtual void initProjectile(SpawnedObject objDetails, ProjectileDetails projDetails)
 {
     base.init(objDetails);
     details = projDetails;
     StartCoroutine(rangeTime(projDetails.range));
 }
 public void SpawnProjectile(ProjectileDetails projDetails)
 {
     _pool.Spawn(projDetails);
 }