Example #1
0
    public void GenericProjectileFire(GameObject useProjectile, GameObject spawnPoint,
                                      ShotDirection shotDirection)
    {
        CurrentProjectile = null;
        CurrentProjectile = starGameManagerRef.SpawnedChecker(useProjectile);

        if (CurrentProjectile == null)
        {
            return;
        }

        CurrentProjectile.transform.SetParent(starGameManagerRef.ActorsParent.transform, false);

        // useObject.transform.SetParent(starGameManagerRef.ActorsParent.transform, true);
        //  useObject.transform.localPosition = spawnPoint.transform.localPosition;
        CurrentProjectile.transform.position = spawnPoint.transform.position;

        CurrentProjectile.transform.rotation = spawnPoint.transform.rotation;


        if (CurrentProjectile.GetComponent <StarProjectileAnim>())
        {
            CurrentProjectile.GetComponent <StarProjectileAnim>().shotDirection = shotDirection;
        }
        CurrentProjectile.SetActive(true);
    }
Example #2
0
 public virtual void Awake()
 {
     shotDirection     = GetComponentInChildren <ShotDirection>();
     deathMessage      = GetComponentInChildren <DeathMessage>();
     healthBar         = GetComponentInChildren <HealthBar>();
     weaponStatCompare = GetComponentInChildren <WeaponStatCompare>();
     aimUi             = GetComponentInChildren <AimUi>();
 }
Example #3
0
 public static void CheckDirection(int chosenDirection, ShotDirection[] directionsOrder,
                                   ref int iterationNumber, ref ShotDirection currentDirection)
 {
     if (currentDirection.HasFlag((ShotDirection)chosenDirection))
     {
         iterationNumber--;
     }
     else
     {
         directionsOrder[iterationNumber] = (ShotDirection)chosenDirection;
         currentDirection += chosenDirection;
     }
 }
Example #4
0
    /// <summary>
    /// Returns the type of shot the player should take.
    /// </summary>
    public ShotType GetTypeOfShot(Player p, float dist, ShotDirection direction)
    {
        if (dist < CLOSE_RANGE)
        {
            if (p.isSprinting)
            {
                return(ShotType.DUNK);
            }
            else if (p.isMoving)
            {
                return(ShotType.LAYUP);
            }
        }

        return(ShotType.SHOT);
    }
Example #5
0
    // =================================== Public Functions ===================================

    /***
     * Starting a shot starts here.
     */
    public void OnShoot(ulong netID, Player p, float speed, float targetHeight, float bonusHeight, float startOffset, float endOffset)
    {
        if (!NetworkingManager.Singleton.IsServer)
        {
            return;
        }

        float dist  = Vector3.Distance(p.transform.position, p.LookTarget);
        float angle = Quaternion.Angle(transform.rotation, p.LookRotation);

        m_isShot            = true;
        m_speed             = speed;
        m_targetHeight      = targetHeight;
        m_targetBonusHeight = bonusHeight;
        m_startOffset       = startOffset;
        m_endOffset         = endOffset;
        m_leftHanded        = p.isBallInLeftHand;
        m_direction         = GetShotDirection(angle);
        m_type     = m_shotController.GetTypeOfShot(p, dist, m_direction);
        m_bankShot = IsBankShot(p);

        Debug.LogFormat("{0} : {1}", p.transform.position, p.LookTarget);
        Debug.LogFormat("{0} : {1} : {2}", m_type, dist, m_direction);

        ShotData.Value.shooter    = netID;
        ShotData.Value.position   = p.transform.position;
        ShotData.Value.distance   = dist;
        ShotData.Value.direction  = m_direction;
        ShotData.Value.type       = m_type;
        ShotData.Value.leftHanded = m_leftHanded;
        ShotData.Value.bankshot   = m_bankShot;

        p.InvokeClientRpcOnClient(p.ClientShootBall, p.OwnerClientId, m_type, m_leftHanded, speed, bonusHeight, startOffset, endOffset);

        StartCoroutine(ShotQuality(p));
    }
Example #6
0
        public static ShotDirection[] GetLineDirectionForShoot()
        {
            ShotDirection[] directionsOrder  = new ShotDirection[DIRECTION_COUNT];
            ShotDirection   currentDirection = ShotDirection.NoneDirection;
            int             chosenDirection  = 0;

            for (int i = 0; i < Constants.TENTH_CELL; i++)
            {
                if (i < Constants.FIFTH_CELL)
                {
                    do
                    {
                        chosenDirection = randCoord.Next() % EIGTH_SHOTS;
                    } while (chosenDirection % TWO_SHOTS == 0);
                }
                else
                {
                    if ((i >= Constants.FIFTH_CELL) && (i < SEVEN_SHOTS))
                    {
                        do
                        {
                            chosenDirection = randCoord.Next() % EIGTH_SHOTS;
                        } while ((chosenDirection % TWO_SHOTS != 0) || (chosenDirection == 0) ||
                                 (chosenDirection == EIGTH_SHOTS));
                    }
                    else
                    {
                        if (randCoord.Next() % TWO_SHOTS == 0)
                        {
                            chosenDirection = EIGTH_SHOTS;
                        }
                        else
                        {
                            chosenDirection = 0;
                        }
                    }
                }

                if (chosenDirection == 0)
                {
                    chosenDirection = 1;
                }
                else
                {
                    chosenDirection = (int)Math.Pow(TWO_SHOTS, chosenDirection);
                }

                switch ((ShotDirection)chosenDirection)
                {
                case ShotDirection.TwoCellWestNorth:
                    CheckDirection(chosenDirection, directionsOrder, ref i, ref currentDirection);
                    break;

                case ShotDirection.FourCellWestNorth:
                    CheckDirection(chosenDirection, directionsOrder, ref i, ref currentDirection);
                    break;

                case ShotDirection.SixCellWestNorth:
                    CheckDirection(chosenDirection, directionsOrder, ref i, ref currentDirection);
                    break;

                case ShotDirection.EightCellWestNorth:
                    CheckDirection(chosenDirection, directionsOrder, ref i, ref currentDirection);
                    break;

                case ShotDirection.Center:
                    CheckDirection(chosenDirection, directionsOrder, ref i, ref currentDirection);
                    break;

                case ShotDirection.EightCellEastSouth:
                    CheckDirection(chosenDirection, directionsOrder, ref i, ref currentDirection);
                    break;

                case ShotDirection.SixCellEastSouth:
                    CheckDirection(chosenDirection, directionsOrder, ref i, ref currentDirection);
                    break;

                case ShotDirection.FourCellEastSouth:
                    CheckDirection(chosenDirection, directionsOrder, ref i, ref currentDirection);
                    break;

                case ShotDirection.TwoCellEastSouth:
                    CheckDirection(chosenDirection, directionsOrder, ref i, ref currentDirection);
                    break;

                default:
                    break;
                }
            }

            return(directionsOrder);
        }
Example #7
0
    void DeploySpawn(GameObject currentObject, ShotDirection shotDirection, string animTriggerA, string animTriggerB, SpawnItems spawnItems, GameObject v3coordsOverride,
                     OverrideObject v3CoordsOverrideObject)
    {
        GameObject currentSpawn = null;

        currentSpawn = starGameManagerRef.SpawnedChecker(currentObject);
        if (currentSpawn == null)
        {
            return;
        }

        CheckParentOverrideAssignment();
        currentSpawn.transform.parent = ParentObject.transform;


        if (v3coordsOverride == null)
        {
            AssignPresetPositions();
        }
        else
        {
            V3Coords = new Vector3(v3coordsOverride.transform.localPosition.x, v3coordsOverride.transform.localPosition.y,
                                   v3coordsOverride.transform.localPosition.z);
        }

        currentSpawn.transform.localPosition = V3Coords;
        ShotDirection currentShotDirection = shotDirection;

        if (ShotDirection != ShotDirection.NA)
        {
            currentShotDirection = ShotDirection;
        }


        currentSpawn.transform.localEulerAngles =
            starGameManagerRef.AdjustShotDirection(currentShotDirection);


        if (currentSpawn.GetComponentInChildren <starEnemy>())  // these are for starEnemy followers
        {
            currentSpawn.GetComponentInChildren <starEnemy>().leader      = true;
            currentSpawn.GetComponentInChildren <starEnemy>().grandParent = currentSpawn.transform.parent.gameObject;
            starGameManagerRef.leaderList.Add(currentSpawn); // CAN DELETE LATER
        }

        currentSpawn.SetActive(true);

        //    print("spawned item activated");

        if (currentSpawn.GetComponentInChildren <Animator>())
        {
            /*
             * if (inList.AnimTriggerA != "")
             * {
             *  currentSpawn.GetComponentInChildren<Animator>().SetTrigger(inList.AnimTriggerA);
             * }
             */

            RunAnimTrigger(currentSpawn, animTriggerA);
            RunAnimTrigger(currentSpawn, animTriggerB);
            // RunAnimTrigger(currentSpawn, inList.ExtraAnimTrigger);
        }

        RunSupplySpecialTriggers(currentSpawn, spawnItems);
    }  // end deploySpawn