コード例 #1
0
    public string getPotion(int potionId, bool leftShelf, StatusScript target) //gets potion from recipie
    {
        Vector3 vec = new Vector3(0, 0, 0);                                    //-15,10,0 left 15,10,0 right
        int     location;

        if (leftShelf)
        {
            location = -1;//left=-1 right=1
        }
        else
        {
            location = 1;
        }

        switch (potionId) //case ingredient1 * ingredient2 * ingredient3... etc.
        {
        case (int)Ingredients.batwing * (int)Ingredients.chamomile * (int)Ingredients.moonwater:
            //vec.Set(13*location, 10, 0);
            target.SetStatus(StatusScript.States.sleepy);
            return("Moon Tea");

        case (int)Ingredients.crystal * (int)Ingredients.honey * (int)Ingredients.butterfly:
            vec.Set(15 * location, 10, 0);
            GameObject.Instantiate(Resources.Load("Potions/Liquid gold"), vec, Quaternion.identity); return("Liquid gold");

        default:
            return("None");
        }
    }
コード例 #2
0
    void Start()
    {
        RaycastTrackerScript tracker = GetComponent <RaycastTrackerScript>();
        GameObject           player  = GameObject.FindGameObjectWithTag("Player");//SystemClassにPlayerの参照を持たせておいてそこから持ってくるようにするかも check

        tracker.InitDestination(player.transform);
        enemyManager = SystemClass.enemyManager;
        name         = gameObject.name;//GameObjectと別にする場合は要変更
        status       = GetComponent <StatusScript>();
        palameter    = GetComponent <PalameterScript>();
    }
コード例 #3
0
    private void OnTriggerStay2D(Collider2D other)
    {
        PalameterScript palam  = other.GetComponent <PalameterScript>();
        StatusScript    status = other.GetComponent <StatusScript>();

        if (status != null && status.IsInvincible)
        {
            return;
        }

        palam?.GainDamage(damage);
        status?.EnInvincible();
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        if (buttonPressed)
        {
            countDown -= Time.deltaTime;
            if (countDown <= 0)
            {
                countDown     = baseCountdown;
                buttonPressed = false;
            }
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            GameObject      obj = anyIngredient;
            IngredientValue scr = obj.GetComponent <IngredientValue>();
            GetComponent <Animation>().Play();
            StatusScript statScr = otherPlayer.GetComponent <StatusScript>();
            buttonPressed = true;
            Debug.Log(scr.getPotion(potionId, leftShelf, statScr));
        }
    }
コード例 #5
0
 // Start is called before the first frame update
 void Start()
 {
     rb     = GetComponent <Rigidbody>();
     status = player.GetComponent <StatusScript>();
 }
コード例 #6
0
 void Start()
 {
     statusScript = GameObject.Find ("GUI").GetComponent<StatusScript> ();
     // deafult state = idle
     hasilJawaban = decideState.idle;
 }