Esempio n. 1
0
    public static BattleAction getAction()
    {
        if (instance == null)
        {
            instance = new DoublePunch();
        }

        return(instance);
    }
    /// <summary>
    /// Start is called before the first frame and gets all the needed
    /// components from the puppet, its children and the scene.
    /// </summary>
    void Start()
    {
        // Find the master battle script component. Return an error if it is
        // not found.
        masterBattleScript = GameObject.Find(MASTER_BATTLE_LOOP).
                             GetComponent <MasterBattleScript>();

        if (masterBattleScript == null)
        {
            Debug.LogError("Master Battle Script could not be found!");
        }

        // Find the destination indicator. Return and error if it is not found,
        //  otherwise, un-child it and disable it.
        destinationIndicator = transform.Find(DESTINATION_INDICATOR).gameObject;

        if (destinationIndicator == null)
        {
            Debug.LogError("The Destination Object could not be found in " +
                           gameObject.name);
        }
        else
        {
            destinationIndicator.transform.parent = null;

            enableDestinationIndicator(false);
        }

        // Find the nav mesh agent and remove updated rotation.
        navMeshAgent = GetComponent <NavMeshAgent>();

        navMeshAgent.updateRotation = false;

        // Create a new mesh path for the passive path line to calcualte the
        // predicted movement of the puppet.
        path = new NavMeshPath();

        // Find the line renderer and set its width and position count.
        pathLineRenderer               = GetComponent <LineRenderer>();
        pathLineRenderer.startWidth    = linePathWidth;
        pathLineRenderer.endWidth      = pathLineRenderer.startWidth;
        pathLineRenderer.positionCount = 0;

        // Find the selected indicator. If it cannot be found, throw an error,
        //  otherwise, diable it.
        selectedIndicator = transform.Find(SELECTED_INDICATOR).gameObject;
        if (selectedIndicator == null)
        {
            Debug.LogError("The selected indicator could not be found in "
                           + gameObject.name);
        }
        else
        {
            enableSelectedIndicator(false);
        }

        // Find the main player camera. If it couldnt be found, throw an error.
        player = Camera.main.gameObject;

        if (player == null)
        {
            Debug.LogError("There is no main camera!");
        }

        // Initialize battle actions
        battleActions = new List <BattleAction>();

        // Add punch as basic action all hunters have (if they have a weapon we
        //   could add a system where it removes the punch but for now it is
        //   on all hunters). !!REMEMBER TO DO ANYTHING RELATED TO THE CONNECTED
        //   HUNTER IN THE SET HUNTER FUNCTION!!
        battleActions.Add(Punch.getAction());
        battleActions.Add(DoublePunch.getAction());

        // Finally, set modifiers to 0
        maxSanityModifier        = 0;
        meleeAttackCountModifier = 0;
        actionPointCountModifier = 0;
        actionRefillModifier     = 0;
        toughnessModifier        = 0;
        strengthModifier         = 0;
        movementModifier         = 0;
    }