Example #1
0
    public ManagerIndex initValues;                             //< The ManagerIndex with initialization values for a given tower

    /*
     * private void Update()
     * {
     *  if (GetComponent<DamPlacementLocation>().inUse)
     *  {
     *      if (locationInUse == false)
     *      {
     *          Invoke("SpawnSealion", 5f);
     *      }
     *  }
     *  //myObject.GetComponent<SealionSpawner>().SpawnSealion();
     *  //just here to save the code
     * }
     */

    /*
     * Awake is called after the initialization of gameobjects prior to the start of the game. This is used as an Initialization Function
     */
    private void Awake()
    {
        // Get initialization values and set this towers basic values
        initValues = FindObjectOfType <ManagerIndex>();
        GameEvents.onTurnUpdated.AddListener(SpawnSealion);
        damPlacementLocation = GetComponent <DamPlacementLocation>();
        turnsBeforeShowing   = initValues.initSets[initValues.setToUse].sealionAppearanceTime;
    }
Example #2
0
    /**
     * Place the dam onto the game map
     */
    public void Place(RaycastHit primaryHitInfo, List <RaycastHit> secondaryHitInfo)
    {
        // can only place if we are over a dam placement location
        DamPlacementLocation placementLocation = primaryHitInfo.collider.gameObject.GetComponent <DamPlacementLocation>();

        if (placementLocation != null)
        {
            placementLocation.AttachDam(this);
        }
    }
Example #3
0
    // initialized in Unity
    // Project -> Assets -> Prefabs -> Filters -> Dam -> DamLadder
    // (make sure to double click on DamLadder cube symbol.

    #region IDragAndDropObject Implementation

    /**
     * Place the dam onto the game map
     */
    public void Place(RaycastHit primaryHitInfo, List <RaycastHit> secondaryHitInfo)
    {
        // can only place if we are there is a dam placement location somewhere in the hit object's hierarchy
        DamPlacementLocation placementLocation = primaryHitInfo.collider.transform.root.GetComponentInChildren <DamPlacementLocation>();

        if (placementLocation != null)
        {
            placementLocation.AttachLadder(this);
        }
    }
Example #4
0
 /**
  * Turn a subset of visualizations on or off
  *
  * @param type System.Type The type of the object we are displaying visualizations for
  * @param activate bool True if we want to activate the visualizations, false if we want to deactivate
  */
 public void DisplayVisualization(System.Type type, bool activate)
 {
     // look through different types to figure out which visualizations to turn on and off
     if (type == typeof(Dam))
     {
         // show placement locations for dams
         DamPlacementLocation.SetDamVisualizations(activate);
     }
     else if (type == typeof(DamLadder))
     {
         // show placement locations for dam ladders
         DamPlacementLocation.SetLadderVisualizations(activate);
     }
 }
Example #5
0
    /**
     * Figure out if we can place the dam at the location of a given raycast
     */
    public bool PlacementValid(RaycastHit primaryHitInfo, List <RaycastHit> secondaryHitInfo)
    {
        // must have hit something
        if (primaryHitInfo.collider)
        {
            DamPlacementLocation placementLocation = primaryHitInfo.collider.gameObject.GetComponent <DamPlacementLocation>();

            // thing we hit must be a dam placement location
            if (placementLocation != null)
            {
                // only return true if the placement location is not already in use
                return(!placementLocation.inUse);
            }
        }

        return(false);
    }
    /**
     * Figure out if we can place the dam at the location of a given raycast
     */
    public override bool PlacementValid(RaycastHit primaryHitInfo, List <RaycastHit> secondaryHitInfo)
    {
        // Must have hit something
        if (primaryHitInfo.collider)
        {
            // Can only place if we are there is a dam placement location somewhere in the hit object's hierarchy
            DamPlacementLocation placementLocation = primaryHitInfo.collider.transform.root.GetComponentInChildren <DamPlacementLocation>();

            // Thing we hit must be a dam placement location
            if (placementLocation != null)
            {
                // Only return true if the placement location is not already in use
                return(placementLocation.inUse && !placementLocation.HasLadder);
            }
        }

        return(false);
    }
Example #7
0
    /**
     * Place the dam onto the game map
     *
     * @param primaryHitInfo The information from the raycast originating from the camera.
     * @param secondaryHitInfo The information from the raycasts surrounding the tower being placed.
     */
    public override void Place(RaycastHit primaryHitInfo, List <RaycastHit> secondaryHitInfo)
    {
        if (!ManagerIndex.MI.TowerManager.GetTower(TowerType.Dam).CanAfford())
        {
            Debug.Log("Insufficient Funds!");
            return;
        }

        // Can only place if we are over a dam placement location
        DamPlacementLocation placementLocation = primaryHitInfo.collider.gameObject.GetComponent <DamPlacementLocation>();

        if (placementLocation != null)
        {
            placementLocation.AttachDam(this);
            initValues.damPresent = 1;
            towerManager.AddTower(this);
            turnPlaced = GameManager.Instance.Turn;
        }
    }
    /**
     * Place the dam onto the game map
     */
    public override void Place(RaycastHit primaryHitInfo, List <RaycastHit> secondaryHitInfo)
    {
        // Can only place if we are there is a dam placement location somewhere in the hit object's hierarchy
        DamPlacementLocation placementLocation = primaryHitInfo.collider.transform.root.GetComponentInChildren <DamPlacementLocation>();

        if (placementLocation != null)
        {
            placementLocation.AttachLadder(this);

            // Initialize the pass rates
            smallCrossingRate  = initValues.initSets[initValues.setToUse].ladderSmallPassRate;
            mediumCrossingRate = initValues.initSets[initValues.setToUse].ladderMediumPassRate;
            largeCrossingRate  = initValues.initSets[initValues.setToUse].ladderLargePassRate;

            initValues.ladderCode = 1;
            towerManager.AddTower(this);
            turnPlaced = GameManager.Instance.Turn;
        }
    }