public void reset()
 {
     destination.Clear();
     previousPos = transform.position;
     state       = charState.idle;
     place       = 0;
 }
Example #2
0
File: MemeSM.cs Project: irs37/MMA
 void Start()
 {
     memehp.text = meme.stat.HP.ToString();
     curState    = charState.PROCESSING;
     Selector.SetActive(false);
     ipos = transform.position;
     BSM  = GameObject.FindGameObjectWithTag("BattleSystem").GetComponent <BattleSM>();
 }
Example #3
0
File: MemeSM.cs Project: irs37/MMA
    void Update()
    {
        memehp.text = meme.stat.HP.ToString();
        Debug.Log(memehp.text)
        updatehp();
        switch (curState)
        {
        case (charState.PROCESSING): {
            updatebar();
            break;
        }

        case (charState.ACTION):
        {
            StartCoroutine((aksi()));
            break;
        }

        case (charState.WAITING):
        {
            if ((isSelected) && (target))
            {
                curState = charState.ACTION;
            }
            break;
        }

        case (charState.SELECTED):
        {
            break;
        }

        case (charState.DEAD):
        {
            break;
        }

        case (charState.ADDTOLIST):
        {
            BSM.playerMeme.Add(this.gameObject);
            curState = charState.WAITING;
            break;
        }
        }

        if (Input.GetMouseButtonDown(0))
        {
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit, 100))
            {
                if (hit.transform.tag == "Enemy")
                {
                    target = hit.transform.gameObject;
                    target.transform.Find("Targeted").gameObject.SetActive(true);
                }
            }
        }
    }
 public void damage(int amount)
 {
     health += amount;
     statusBar.updateHealth(health, maxHealth);
     if (health <= 0)
     {
         state = charState.dead;
     }
 }
 void Awake()
 {
     destination = new List <Vector3>();
     previousPos = transform.position;
     state       = charState.idle;
     place       = 0;
     statusBar.updateHealth(health, maxHealth);
     statusBar.updateEnd(endurance, maxEndurance);
 }
Example #6
0
File: MemeSM.cs Project: irs37/MMA
 public void TakeDamage(float amount)
 {
     meme.stat.HP -= amount;
     if (meme.stat.HP <= 0)
     {
         curState = charState.DEAD;
         Debug.Log(curState);
     }
 }
Example #7
0
File: MemeSM.cs Project: irs37/MMA
    void updatebar()
    {
        cur_cooldown = cur_cooldown + Time.deltaTime;
        float calc_cooldown = cur_cooldown / max_cooldown;

        if (cur_cooldown > max_cooldown)
        {
            curState = charState.WAITING;
        }
    }
Example #8
0
 // Start is called before the first frame update
 void Start()
 {
     playerState     = charState.Asleep;
     energy          = 0.0f; // Player starts with 0 energy
     energyDrainTime = 0.3f; // Energy drains every x seconds
     playerPos       = GetComponent <Transform>();
     inventory       = null;
     inventoryUI     = GameObject.FindGameObjectWithTag("Inventory");
     inventoryUI.SetActive(false);
     gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
 }
Example #9
0
        Inventory inventory; //character inventory - incudes all character items

        #endregion Fields

        #region Constructors

        public Character(StatSheet stats, Profession profession, Vector2 startPosition, bool ally = false)
        {
            this.stats = stats;
            this.profession = profession;
            this.position = startPosition;
            this.ally = ally;
            this.selected = false;
            this.state = charState.still;
            this.characterSpriteOffsetX = (int)Profession.getOffset(profession).X;
            int characterSpriteOffsetY = (int)Profession.getOffset(profession).Y;
            this.pixelPosition = this.getPixelPositionByTilePosition(startPosition);
        }
Example #10
0
    private void CheckPlayerState()
    {
        if (energy <= 0f) // If the player has no energy and the grace period has expired
        {
            if (gameManager.gracePeriod == false)
            {
                gameManager.fellAsleep = true;
            }

            playerState = charState.Asleep; // They fall asleep
            sleeping.SetActive(true);
        }

        else
        {
            playerState = charState.Awake;
            sleeping.SetActive(false);
        }
    }
 void FixedUpdate()
 {
     if (state == charState.move)
     {
         if (destination.Count - place == 0)
         {
             Debug.Log("STOP");
             game.gameController.EndBattle();
         }
         else if (place < destination.Count)
         {
             if (game.gameController.characterLocations[game.map.ToTileCoordinates(destination[place])])
             {
                 Debug.Log("Fight");
                 state = charState.attack;
                 game.gameController.StartBattle(game.gameController.characterLocations[game.map.ToTileCoordinates(destination[place])].gameObject, ally);
                 place = 0;
             }
             else if (Vector3.Distance(destination[place], transform.position) < 0.01f)
             {
                 ++place;
                 Debug.Log("NEXT");
                 game.gameController.SetCharacterLocation(gameObject, previousPos);
                 previousPos = transform.position;
             }
             else
             {
                 transform.position = Vector3.MoveTowards(transform.position, destination[place], Time.deltaTime * 3);
             }
         }
     }
     else if (state == charState.attack)
     {
     }
     else if (state == charState.dead)
     {
         game.gameController.removeChar(gameObject, ally);
         transform.position = new Vector3(transform.position.x, 0.0f, transform.position.z);
         state = charState.idle;
     }
 }
Example #12
0
File: MemeSM.cs Project: irs37/MMA
    private IEnumerator aksi()
    {
        if (action)
        {
            yield break;
        }

        action = true;

        Vector3 targetpos = new Vector3(target.transform.position.x - 1.5f, target.transform.position.y, target.transform.position.z);

        while (movetarget(targetpos))
        {
            yield return(null);
        }

        DoDamage();

        yield return(new WaitForSeconds(0.5f));

        Vector3 spos = ipos;

        while (moveipos(spos))
        {
            yield return(null);
        }

        BSM.action.RemoveAt(0);
        BSM.bs = BattleSM.battleState.WAIT;

        action = false;
        Selector.SetActive(false);
        isSelected = false;
        target.transform.Find("Targeted").gameObject.SetActive(false);
        target   = null;
        curState = charState.WAITING;
    }
Example #13
0
 //ステータスを変更するため
 void changeState(charState st)
 {
     state = st;
 }
Example #14
0
	public void SetState(charState newState){
		state = newState;
	}
Example #15
0
 public void changeState(charState s)
 {
     state = s;
 }
    // Update is called once per frame
    void Update()
    {
        float movementX = Input.GetAxisRaw("Horizontal");
        float movementY = Input.GetAxisRaw("Vertical");

        foreach (KeyCode vKey in System.Enum.GetValues(typeof(KeyCode)))
        {
            if (Input.GetKey(vKey))
            {
                //your code here
                //Debug.Log(vKey.ToString());
            }
        }


        // Debug.Log(Input.GetAxis("JOY1"));


        if (Input.GetButtonUp("Xbutton"))
        {
            Debug.Log("X");
        }
        if (Input.GetButtonUp("Ybutton"))
        {
        }


        if (Input.GetButton("Abutton"))
        {
            Debug.Log("A");
        }
        if (Input.GetButton("Bbutton"))
        {
            Debug.Log("B");
        }

        if (Input.GetAxisRaw("Horizontal") >= 0.01 && playerFace != true)
        {
            playerFace     = true;
            needChangeFace = true;
        }
        else if (Input.GetAxisRaw("Horizontal") <= -0.01 && playerFace != false)
        {
            playerFace     = false;
            needChangeFace = true;
        }


        if (needChangeFace)
        {
            needChangeFace = false;
            ts.localScale  = new Vector3(ts.localScale.x * -1, ts.localScale.y, 1);
        }

        // playerStateSet
        if ((rb2d.velocity.x > 0.1 && rb2d.velocity.y <= 0.01) || (rb2d.velocity.x < -0.1 && rb2d.velocity.y >= -0.01))
        {
            playerState = charState.walking;
        }
        else
        {
            playerState = charState.landed;
        }

        //Debug.Log(rb2d.velocity);
        //Debug.Log(playerState.ToString());

        Vector3 v3 = new Vector3(movementX, movementY, 0);

        rb2d.AddForce(v3 * movespeed * Time.deltaTime, ForceMode2D.Impulse);
        //ts.position += v3 * speed * Time.deltaTime;
    }